mapbox component jest tests #311
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
added jest tests for Mapbox component, specifically for the two prop fields:
getCoordinate
andonDrag
. The remaining props are best tested through storybook.note that
mapbox-gl
is mocked as it seems to use some web browser functionality on initialization that is not supported in jest test environment (jsdom). Without mocking, jest would present an errorError: Failed to initialize WebGL.
.jest-webgl-canvas-mock
andjest-canvas-mock
still result in more window properties access related errors ([TypeError: e.window.Worker is not a constructor]
, which could be resolve by manually mocking Worker,[TypeError: this.target.addEventListener is not a function]
...).yext/components-tsx-maps
and the assertions in the unit tests seem to check for the rendering of the wrapper component only and not waiting for the script to load. No content/interaction of the map was tested from my understanding.I decided this complexity is probably unnecessary to add to the repo but we can discuss if other may think differently. We can have jest strictly test new isolated functionalities added from the component and leave all the UI rendering and mapbox interaction to storybook tests.
SLAP-2222
TEST=auto
new jest tests passed