This PR adds Jest and Enzyme in order to fully test the component functionality. I had to make some small changes to the project setup as well as the component to get everything to play nice.
Jest cannot by default handle CSS module imports. As such I created a config directory in which there is a stub named "CSSStub.js". This is passed to Jest to stub CSS imports.
Fetch needs to be mocked in the tests (since we're not testing whether Fetch works). I added a mocks directory in which there is a mock json mapbox response and a mock Fetch Response object. These are used in the tests to mock the Fetch interactions.
jsdom doesn't support dataset as noted here: https://github.com/tmpvar/jsdom/issues/961 the current recommendation is to use currentTarget.getAttribute and I had to make this change in order to properly test _onSuggestionSelect.
Removed . from Lodash methods in component. This was breaking the tests and there's no need for the global reference when importing the individual methods.
This PR adds Jest and Enzyme in order to fully test the component functionality. I had to make some small changes to the project setup as well as the component to get everything to play nice.
currentTarget.getAttribute
and I had to make this change in order to properly test_onSuggestionSelect
.To do: