Skip to content

Commit

Permalink
test(highlight-matched-substrings): add test for multiple matched sub…
Browse files Browse the repository at this point in the history
…strings
  • Loading branch information
plumdumpling committed Aug 9, 2023
1 parent 0848408 commit 505389c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/Geosuggest_spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -870,13 +870,28 @@ describe('Component: Geosuggest', () => {
expect(matchedText).to.have.lengthOf.at.least(1);
});

it('should render a match with minial nodes', () => {
it('should highlight multiple matched substrings', () => {
const geoSuggestInput = component.container.querySelector(
'.geosuggest__input'
) as HTMLInputElement;
fireEvent.change(geoSuggestInput, {target: {value: 'Newa'}});
geoSuggestInput.focus();

const geoSuggestItems =
component.container.getElementsByClassName('geosuggest__item');
const matchedText = geoSuggestItems[0].getElementsByClassName(
'geosuggest__item__matched-text'
);
expect(matchedText).to.have.lengthOf(2);
});

it('should render a match with minimal nodes', () => {
const geoSuggestInput = component.container.querySelector(
'.geosuggest__input'
) as HTMLInputElement;
fireEvent.change(geoSuggestInput, {target: {value: 'New Jersey'}});
geoSuggestInput.focus();

const geoSuggestItems =
component.container.getElementsByClassName('geosuggest__item');
expect(geoSuggestItems).to.have.lengthOf(1);
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/predictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export default function predictions(): google.maps.places.AutocompletePrediction
{
length: 2,
offset: 0
},
{
length: 2,
offset: 8
}
],
place_id: 'ChIJHQ6aMnBTwokRc-T-3CrcvOE',
Expand Down

0 comments on commit 505389c

Please sign in to comment.