mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-19 13:56:58 -04:00
* Bugfix: TaxonDetails was crashing if it received a null taxon * Send lat and lng instead of latitude and longitude to the score_image endpoint * Show offline suggestions when you are offline * Show notice when viewing offline suggestions * Moved code unique to useOnlineSuggestions into that file * Ensure we use a medium size image to get suggestions when dealing with remote URLs * More logging around React Query retries * Use default retry logic for useAuthenticatedQuery * Made a module-resolver shortcut for tests * Move offline notice above top suggestion; hide when offlines exist but onlines do too
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { faker } from "@faker-js/faker";
|
|
import { render, screen } from "@testing-library/react-native";
|
|
import PhotoScroll from "components/SharedComponents/PhotoScroll";
|
|
import _ from "lodash";
|
|
import React from "react";
|
|
import factory from "tests/factory";
|
|
|
|
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.number.int( ),
|
|
attribution: faker.lorem.sentence( ),
|
|
licenseCode: "cc-by-nc",
|
|
url: faker.image.url( )
|
|
}
|
|
} )
|
|
]
|
|
} );
|
|
|
|
const mockPhotos = _.compact(
|
|
Array.from( mockObservation.observationPhotos ).map( op => op.photo )
|
|
);
|
|
|
|
describe( "PhotosScroll", () => {
|
|
it.todo( "should not have accessibility errors" );
|
|
// it( "should not have accessibility errors", async () => {
|
|
// const photoScroll = <PhotoScroll photos={mockPhotos} />;
|
|
// expect( photoScroll ).toBeAccessible( );
|
|
// } );
|
|
|
|
it( "should show the main carousel", async () => {
|
|
render( <PhotoScroll photos={mockPhotos} /> );
|
|
expect( screen.getByTestId( "photo-scroll" ) ).toBeTruthy();
|
|
} );
|
|
|
|
it( "should show photo with given url", async () => {
|
|
render( <PhotoScroll photos={mockPhotos} /> );
|
|
const photo = await screen.findByTestId( "PhotoScroll.photo" );
|
|
expect( photo.props.source ).toStrictEqual(
|
|
{
|
|
uri: mockObservation.observationPhotos[0].photo.url
|
|
}
|
|
);
|
|
} );
|
|
} );
|