mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-25 01:11:22 -04:00
Primarily adds designed layouts for permission gates (also referred to as permissions priming). * moved permission gate business logic into a container * use react-native-permissions exclusively * Show PermissionGate as a modal * Basic unit tests for PermissionGate * Consistent content width on tablet, other minor style changes * Allow PermissionGate to be used outside of nav hierarchy * Use user location on Explore after getting permission * Remove redundant 'always' location perm in ios * Isolate current location button in the Map component, which uses location fetching functionality from react-native-maps instead of our own * Updated cocoapods; matched INatIcon.ttf to sha1 hashes
47 lines
1.4 KiB
JavaScript
47 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
|
|
withObsTiles
|
|
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( ) )}
|
|
/>
|
|
);
|
|
const testId = "Map.LocationIndicator";
|
|
expect( screen.getByTestId( testId ) ).toBeTruthy();
|
|
} );
|
|
} );
|