Files
iNaturalistReactNative/tests/unit/components/SharedComponents/Map.test.js
Amanda Bullington 9ada594505 Show taxon pins on Explore Map (#778)
* Show taxon pins on Explore Map; allow navigation; closes #750

* Add test coverage for Map component

* Calculations for UTF position

* Map tiles pressable with UTF Grid overlay

* Fix tests

* Clean up tests
2023-09-21 16:08:39 -07:00

45 lines
1.4 KiB
JavaScript

import { faker } from "@faker-js/faker";
import { screen } from "@testing-library/react-native";
import { Map } from "components/SharedComponents";
import React from "react";
import { renderComponent } from "../../../helpers/render";
const mockNavigate = jest.fn( );
jest.mock( "@react-navigation/native", () => {
const actualNav = jest.requireActual( "@react-navigation/native" );
return {
...actualNav,
useNavigation: () => ( {
navigate: mockNavigate
} )
};
} );
describe( "Map", ( ) => {
it( "should be accessible", ( ) => {
expect( <Map /> ).toBeAccessible( );
} );
it( "displays filtered observations on map", async ( ) => {
renderComponent( <Map tileMapParams={{
taxon_id: 47178
}}
/> );
const tiles = await screen.findByTestId( "Map.UrlTile" );
expect( tiles ).toHaveProp( "urlTemplate", "https://api.inaturalist.org/v2/grid/{z}/{x}/{y}.png?taxon_id=47178&color=%2374ac00&verifiable=true" );
} );
it( "displays location indicator when given an observation lat/lng", async ( ) => {
renderComponent(
<Map
showLocationIndicator
obsLatitude={Number( faker.address.latitude( ) )}
obsLongitude={Number( faker.address.longitude( ) )}
/>
);
expect( screen.getByTestId( "Map.LocationMarkerImage" ).props.source )
.toStrictEqual( require( "images/location_indicator.png" ) );
} );
} );