Files
iNaturalistReactNative/tests/unit/components/SharedComponents/ObservationsFlashList/ObsUploadStatus.test.js
Ken-ichi f7dc08a704 Suggestions fixes (#972)
* 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
2023-12-15 19:58:12 -08:00

78 lines
2.0 KiB
JavaScript

import { faker } from "@faker-js/faker";
import {
screen
} from "@testing-library/react-native";
import ObsUploadStatus from "components/SharedComponents/ObservationsFlashList/ObsUploadStatus";
import initI18next from "i18n/initI18next";
import i18next from "i18next";
import React from "react";
import factory from "tests/factory";
import { renderComponent } from "tests/helpers/render";
const mockUnsyncedObservation = factory( "LocalObservation", {
_synced_at: null
} );
const mockEditedObservation = factory( "LocalObservation", {
_synced_at: faker.date.past( ),
_updated_at: faker.date.future( )
} );
describe( "ObsUploadStatus", () => {
beforeAll( async () => {
await initI18next();
} );
it( "displays a pending upload for an unsynced observation", () => {
renderComponent(
<ObsUploadStatus
observation={mockUnsyncedObservation}
showUploadStatus
progress={0}
/>
);
const icon = screen.getByLabelText( i18next.t( "Start-upload" ) );
expect( icon ).toBeVisible( );
} );
it( "displays a pending upload for a locally edited observation", () => {
renderComponent(
<ObsUploadStatus
observation={mockEditedObservation}
showUploadStatus
progress={0}
/>
);
const icon = screen.getByLabelText( i18next.t( "Start-upload" ) );
expect( icon ).toBeVisible( );
} );
it( "displays an upload in progress", async ( ) => {
renderComponent(
<ObsUploadStatus
observation={mockUnsyncedObservation}
showUploadStatus
progress={0.05}
/>
);
const progressIcon = screen.getByLabelText( i18next.t( "Upload-in-progress" ) );
expect( progressIcon ).toBeVisible( );
} );
it( "displays a completed upload", async () => {
renderComponent(
<ObsUploadStatus
observation={mockUnsyncedObservation}
showUploadStatus
progress={1}
/>
);
const a11yLabel = screen.getByLabelText( i18next.t( "Upload-Complete" ) );
expect( a11yLabel ).toBeVisible( );
} );
} );