mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 05:58:37 -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
66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
import { render, screen } from "@testing-library/react-native";
|
||
import PermissionGate from "components/SharedComponents/PermissionGate";
|
||
import initI18next from "i18n/initI18next";
|
||
import React from "react";
|
||
import { RESULTS } from "react-native-permissions";
|
||
|
||
describe( "PermissionGate", ( ) => {
|
||
beforeAll( async ( ) => {
|
||
await initI18next( );
|
||
} );
|
||
|
||
it( "should show the GRANT PERMISSION button when permission unknown", ( ) => {
|
||
render(
|
||
<PermissionGate
|
||
requestPermission={jest.fn( )}
|
||
grantStatus={null}
|
||
onClose={jest.fn( )}
|
||
/>
|
||
);
|
||
expect( screen.getByText( "GRANT PERMISSION" ) ).toBeTruthy( );
|
||
} );
|
||
|
||
it( "should show the GRANT PERMISSION button when permission blocked", ( ) => {
|
||
render(
|
||
<PermissionGate
|
||
requestPermission={jest.fn( )}
|
||
grantStatus={RESULTS.DENIED}
|
||
onClose={jest.fn( )}
|
||
/>
|
||
);
|
||
expect( screen.getByText( "GRANT PERMISSION" ) ).toBeTruthy( );
|
||
} );
|
||
|
||
it( "should show the OPEN SETTINGS button when permission blocked", ( ) => {
|
||
render(
|
||
<PermissionGate
|
||
requestPermission={jest.fn( )}
|
||
grantStatus={RESULTS.BLOCKED}
|
||
onClose={jest.fn( )}
|
||
/>
|
||
);
|
||
expect( screen.getByText( "OPEN SETTINGS" ) ).toBeTruthy( );
|
||
} );
|
||
|
||
it( "should show the blockedPrompt when permission blocked", ( ) => {
|
||
render(
|
||
<PermissionGate
|
||
requestPermission={jest.fn( )}
|
||
grantStatus={RESULTS.BLOCKED}
|
||
onClose={jest.fn( )}
|
||
/>
|
||
);
|
||
expect( screen.getByText( /You’ve denied permission/ ) ).toBeTruthy( );
|
||
} );
|
||
|
||
it( "should be accessible", ( ) => {
|
||
expect(
|
||
<PermissionGate
|
||
requestPermission={jest.fn( )}
|
||
grantStatus={null}
|
||
onClose={jest.fn( )}
|
||
/>
|
||
).toBeAccessible( );
|
||
} );
|
||
} );
|