mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-06 06:35:57 -04:00
* Reorder hooks dependencies * Return uri from take photo hook * Keep state of photos added in this instance of the camera * List2 TS * INatIconButton TS * Refactor useBackPress to show discard modal only if photos taken during this instance of the camera * Remove newPhotoCount var * TS refactors * fetchUserLocation TS * Increase timeout * Fix error * Hoist deletePhotoByUri * Delete photos on discard * Reorder code * Set saving photo on checkmark press Closes #1556 * Update snapshots * Remove delete test * Create StandardCamera.test.js * Check if image is there before deletion * Update react-native-share-menu+6.0.0.patch * Update e2e_ios.yml * Update some types
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import {
|
|
render, screen
|
|
} from "@testing-library/react-native";
|
|
import PhotoCarousel from "components/Camera/StandardCamera/PhotoCarousel.tsx";
|
|
import React from "react";
|
|
import useStore from "stores/useStore";
|
|
|
|
jest.mock( "components/MediaViewer/MediaViewerModal", ( ) => jest.fn( ( ) => null ) );
|
|
|
|
const initialStoreState = useStore.getState( );
|
|
|
|
// For snapshots we want test data not to be random
|
|
const mockPhotoUris = [
|
|
"https://inaturalist-open-data.s3.amazonaws.com/photos/1/large.jpeg",
|
|
"https://inaturalist-open-data.s3.amazonaws.com/photos/2/large.jpeg",
|
|
"https://inaturalist-open-data.s3.amazonaws.com/photos/3/large.jpeg"
|
|
];
|
|
|
|
describe( "PhotoCarousel", ( ) => {
|
|
beforeAll( async () => {
|
|
useStore.setState( initialStoreState, true );
|
|
} );
|
|
// There were some tests of photo sizes responding to the isLargeScreen prop
|
|
// but somewhat dynamic tailwind classes don't seem to create style props
|
|
// in a test environment, so I'm not sure we can test those now ~~~kueda
|
|
// 20230518
|
|
it( "renders correctly", async () => {
|
|
render(
|
|
<PhotoCarousel photoUris={mockPhotoUris} />
|
|
);
|
|
|
|
await screen.findByTestId( `PhotoCarousel.displayPhoto.${mockPhotoUris[0]}` );
|
|
|
|
// Snapshot test
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "renders correctly for large screen", async () => {
|
|
render(
|
|
<PhotoCarousel photoUris={mockPhotoUris} isLargeScreen />
|
|
);
|
|
|
|
await screen.findByTestId( `PhotoCarousel.displayPhoto.${mockPhotoUris[0]}` );
|
|
|
|
// Snapshot test
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
} );
|