Skip to content

Commit

Permalink
Added a manual test into the test suite for a 1-character feature fil…
Browse files Browse the repository at this point in the history
…ter item, refactored a little, and confirmed all working for issue #267.
  • Loading branch information
martindholmes committed May 21, 2024
1 parent 45c805c commit 8f57e59
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
11 changes: 7 additions & 4 deletions js/SSTypeAhead.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
* as JSON by the StaticSearch instance which is
* creating this control.
* @param {!string} filterName the textual descriptive name of the
* filter.
* filter.*
* @param {!number} minNameLength the minimum length of textual input that
* will trigger a typeahead search. Normally equal to the
* shortest length of item in the typeahead data list.
*
*/
constructor(rootEl, filterData, filterName, minWordLength){
constructor(rootEl, filterData, filterName, minNameLength){
this.rootEl = rootEl;
this.filterData = filterData;
this.filterName = filterName;
this.minWordLength = minWordLength;
this.minNameLength = minNameLength;
this.reId = /^ssFeat\d+_\d+$/;
//Because so much staticSearch filter handling is based on
//the string values of items rather than ids, we create a map
Expand Down Expand Up @@ -106,7 +109,7 @@
* matches.
*/
populate(){
if ((this.populating)||(this.input.value.length < this.minWordLength)){
if ((this.populating)||(this.input.value.length < this.minNameLength)){
return;
}
this.populating = true;
Expand Down
2 changes: 1 addition & 1 deletion js/StaticSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class StaticSearch{
* control and assigns functionality events to it.
* @param {!string} filterId the id of the filter to set up.
* @param {!string} filterName the string name of the filter.
* @param {!string} minNameLength the minimum length for the string
* @param {!number} minNameLength the minimum length for the string
* a user types into the control at which a search
* of the filter values will be initiated.
* @return {boolean} true if a filter is found and set up, else false.
Expand Down
23 changes: 12 additions & 11 deletions test/apostrophes.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
<meta name="Worth reading" class="staticSearch_bool" content="true" />
<meta name="docSortKey" class="staticSearch_docSortKey" content="ddd"/>
<meta name="docTitle" class="staticSearch_docTitle myMeta" content="Porter, 'Apostrophe'"/>
<meta name="People involved" class="staticSearch_feat" content="Martin Holmes"/>
<meta name="People involved" class="staticSearch_feat" content="Joey Takeda"/>
<meta name="People involved" class="staticSearch_feat" content="Captain Janeway"/>
<meta name="People involved" class="staticSearch_feat" content="Ada Lovelace"/>
<meta name="People involved" class="staticSearch_feat" content="John Stow"/>
<meta name="People involved" class="staticSearch_feat" content="Joan Clarke"/>
<meta name="People involved" class="staticSearch_feat" content="Émilie du Châtelet"/>
<meta name="People involved" class="staticSearch_feat" content="Moribund the Burgermeister"/>
<meta name="People involved" class="staticSearch_feat" content="Alfred Lord Tennyson"/>
<meta name="People involved" class="staticSearch_feat" content="Grace Hopper"/>
<meta name="People involved" class="staticSearch_feat" content="Sir James Douglas"/>
<meta name="People involved" class="staticSearch_feat" content="Martin Holmes"/>
<meta name="People involved" class="staticSearch_feat" content="Joey Takeda"/>
<meta name="People involved" class="staticSearch_feat" content="Captain Janeway"/>
<meta name="People involved" class="staticSearch_feat" content="Ada Lovelace"/>
<meta name="People involved" class="staticSearch_feat" content="John Stow"/>
<meta name="People involved" class="staticSearch_feat" content="Joan Clarke"/>
<meta name="People involved" class="staticSearch_feat" content="Émilie du Châtelet"/>
<meta name="People involved" class="staticSearch_feat" content="Moribund the Burgermeister"/>
<meta name="People involved" class="staticSearch_feat" content="Alfred Lord Tennyson"/>
<meta name="People involved" class="staticSearch_feat" content="Grace Hopper"/>
<meta name="People involved" class="staticSearch_feat" content="Sir James Douglas"/>
<meta name="People involved" class="staticSearch_feat" content="X"/>
<style>
body{
max-width: 45rem;
Expand Down
1 change: 1 addition & 0 deletions test/clues.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<meta name="People involved" class="staticSearch_feat" content="John Stow"/>
<meta name="People involved" class="staticSearch_feat" content="Joan Clarke"/>
<meta name="People involved" class="staticSearch_feat" content="Émilie du Châtelet"/>
<meta name="People involved" class="staticSearch_feat" content="X"/>

<style>
div.text{
Expand Down
7 changes: 4 additions & 3 deletions test/tables/booze.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<meta name="Random numeric value" class="staticSearch_desc" content="21" />
<meta name="Number of animal names" class="staticSearch_num" content="1"/>
<meta name="docImage" class="staticSearch_docImage" content="../images/booze.png" />
<meta name="People involved" class="staticSearch_feat" content="Martin Holmes"/>
<meta name="People involved" class="staticSearch_feat" content="Joey Takeda"/>
<meta name="People involved" class="staticSearch_feat" content="Sir James Douglas"/>
<meta name="People involved" class="staticSearch_feat" content="Martin Holmes"/>
<meta name="People involved" class="staticSearch_feat" content="Joey Takeda"/>
<meta name="People involved" class="staticSearch_feat" content="Sir James Douglas"/>
<meta name="People involved" class="staticSearch_feat" content="X"/>
<script src="../ssTest/ssHighlight.js"> </script>
</head>
<body>
Expand Down

0 comments on commit 8f57e59

Please sign in to comment.