Files
iNaturalistReactNative/tests/unit/components/SharedComponents/Map.test.js
Ken-ichi 4ccf9e750b Explore fixes (#1169)
* Separate zoom to user loc from nearby; fix Android map crash; disable map pitch and rotate
* Ensure Explore shows nearby observations after permission granted
* Ensure Explore shows nearby observations even when defaulting to grid/list
  view
* Don't default the map to showing verifiable obs (this isn't the map's
  responsibility, sometimes we want to map casual obs)
* Remove extraneous current location button on map (closes #941)
* Bugfix: Explore user filter didn't let you choose a user
* Remove place params for bounding box searches and vice versa
* Prevent Explore list and map from re-rendering every time you come back to Explore
* Fixed Explore header count overflow style
* Bugfix: Explore filters weren't 100% width on iPad
* More layout fixes; fixed bug w/ UserProfile when zero idents
2024-02-23 19:55:25 -08:00

40 lines
1.2 KiB
JavaScript

import { screen } from "@testing-library/react-native";
import { Map } from "components/SharedComponents";
import React from "react";
import faker from "tests/helpers/faker";
import { renderComponent } from "tests/helpers/render";
const baseUrl = "https://api.inaturalist.org/v2/grid/{z}/{x}/{y}.png";
describe( "Map", ( ) => {
it( "should be accessible", ( ) => {
expect( <Map /> ).toBeAccessible( );
} );
it( "displays filtered observations on map", async ( ) => {
const taxonId = 1234;
renderComponent(
<Map
withPressableObsTiles
tileMapParams={{ taxon_id: taxonId }}
/>
);
const tiles = await screen.findByTestId( "Map.UrlTile" );
const { urlTemplate } = tiles.props;
expect( urlTemplate )
.toMatch( new RegExp( `^${baseUrl}.*taxon_id=${taxonId}` ) );
} );
it( "displays location indicator when given an observation lat/lng", async ( ) => {
renderComponent(
<Map
showLocationIndicator
obsLatitude={Number( faker.location.latitude( ) )}
obsLongitude={Number( faker.location.longitude( ) )}
/>
);
const testId = "Map.LocationIndicator";
expect( screen.getByTestId( testId ) ).toBeTruthy();
} );
} );