Files
iNaturalistReactNative/tests/unit/components/SharedComponents/UploadStatus/UploadStatus.test.js
Angie fb23d925c4 400 uploadstatus component (#488)
* UploadStatus component

* Added UploadStatus to SharedComponents/index.js

* Change upload complete icon and color

* QualityGradeStatus accessibility labels

* Saved Observation Animation for UploadStatus

* Changed widths of component

* Unit test for UploadStatus

* Unit test and snapshot for UploadStatus

* Update snapshot tests

* Changes requested, accessibility labels for UploadStatus progress, accessibility tests

* Update snapshot tests

* Testing updated snapshot test

* Fix style

* And again

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2023-03-09 17:49:32 +01:00

41 lines
1.5 KiB
JavaScript

import { render, screen } from "@testing-library/react-native";
import { UploadStatus } from "components/SharedComponents";
import React from "react";
jest.mock( "react-native-circular-progress-indicator", () => "CircularProgress" );
jest.mock( "react-native/Libraries/Animated/NativeAnimatedHelper" );
describe( "UploadStatus", () => {
it( "does not show progress bar when progress is less than 5%", async () => {
render( <UploadStatus progress={0.01} color="#454545" completeColor="#77b300" /> );
expect( screen.queryByTestId( "UploadStatus.CircularProgress" ) ).toBeFalsy();
} );
it( "shows progress bar when progress is greater than 5%", async () => {
render( <UploadStatus progress={0.5} color="#454545" completeColor="#77b300" /> );
expect( screen.getByTestId( "UploadStatus.CircularProgress" ) ).toBeTruthy();
} );
it( "displays progress bar when progress is less than 5% correctly", async () => {
render( <UploadStatus progress={0.01} color="#454545" completeColor="#77b300" /> );
// Snapshot test
expect( screen ).toMatchSnapshot();
} );
it( "displays progress bar when progress is greater than 5% correctly", async () => {
render( <UploadStatus progress={0.5} color="#454545" completeColor="#77b300" /> );
// Snapshot test
expect( screen ).toMatchSnapshot();
} );
it( "has no accessibility errors", () => {
const uploadStatus = (
<UploadStatus progress={0.5} color="#454545" completeColor="#77b300" />
);
expect( uploadStatus ).toBeAccessible();
} );
} );