Files
iNaturalistReactNative/tests/unit/components/Camera/PhotoCarousel.test.js
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17:13 -06:00

43 lines
1.5 KiB
JavaScript

import {
render, screen,
} from "@testing-library/react-native";
import PhotoCarousel from "components/Camera/StandardCamera/PhotoCarousel";
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]}` );
expect( screen ).toMatchSnapshot();
} );
it( "renders correctly for large screen", async () => {
render( <PhotoCarousel photoUris={mockPhotoUris} isLargeScreen /> );
await screen.findByTestId( `PhotoCarousel.displayPhoto.${mockPhotoUris[0]}` );
expect( screen ).toMatchSnapshot();
} );
} );