mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 14:08:31 -04:00
* Make minimum viable RemoteComment * Minimum vialbe RemoteIdentification * Minimum viable remote project, place, and messages * Create minimum viable records for all remote factories * Remove factories for local device data * Minimum viable local taxon, comment, id * Minimum viable for local observation photo (photo has no primary key) * Minimum viable LocalUser * Minimum viable record for LocalObservation
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
import { faker } from "@faker-js/faker";
|
|
import { screen } from "@testing-library/react-native";
|
|
import PhotoScroll from "components/SharedComponents/PhotoScroll";
|
|
import _ from "lodash";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
const mockObservation = factory( "LocalObservation", {
|
|
created_at: "2022-11-27T19:07:41-08:00",
|
|
time_observed_at: "2023-12-14T21:07:41-09:30",
|
|
observationPhotos: [
|
|
factory( "LocalObservationPhoto", {
|
|
photo: {
|
|
id: faker.datatype.number( ),
|
|
attribution: faker.lorem.sentence( ),
|
|
licenseCode: "cc-by-nc",
|
|
url: faker.image.imageUrl( )
|
|
}
|
|
} )
|
|
]
|
|
} );
|
|
|
|
const mockPhotos = _.compact(
|
|
Array.from( mockObservation.observationPhotos ).map( op => op.photo )
|
|
);
|
|
|
|
describe( "PhotosScroll", () => {
|
|
test( "should not have accessibility errors", async () => {
|
|
const photoScroll = <PhotoScroll photos={mockPhotos} />;
|
|
|
|
expect( photoScroll ).toBeAccessible();
|
|
} );
|
|
|
|
test( "should render correctly", async () => {
|
|
renderComponent( <PhotoScroll photos={mockPhotos} /> );
|
|
|
|
const photoScroll = await screen.findByTestId( "photo-scroll" );
|
|
|
|
expect( photoScroll ).toBeTruthy();
|
|
} );
|
|
|
|
test( "should show photo with given url", async () => {
|
|
renderComponent( <PhotoScroll photos={mockPhotos} /> );
|
|
|
|
const photo = await screen.findByTestId( "PhotoScroll.photo" );
|
|
|
|
expect( photo.props.source ).toStrictEqual(
|
|
{
|
|
uri: mockObservation.observationPhotos[0].photo.url
|
|
}
|
|
);
|
|
} );
|
|
} );
|