diff --git a/test/Geosuggest_spec.tsx b/test/Geosuggest_spec.tsx index 65fc1c4..c8d0dc4 100644 --- a/test/Geosuggest_spec.tsx +++ b/test/Geosuggest_spec.tsx @@ -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); diff --git a/test/fixtures/predictions.ts b/test/fixtures/predictions.ts index 02a6ed1..060290c 100644 --- a/test/fixtures/predictions.ts +++ b/test/fixtures/predictions.ts @@ -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',