Files
iNaturalistReactNative/tests/unit/components/SharedComponents/PhotoCount/PhotoCount.test.js
Yahia Jabeur 3342dfa9e2 483 create PhotoCount component (#497)
* 483 create PhotoCount component

* 483 PhotoCount refinement

* 483 add PhotoCount component unit test

* 483 add shadow to PhotoCount component

* Use Body3 component instead of SVG text

* 483 fix unit tests

* Find component by text rather than by ID

* Remove unused test id

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2023-03-09 16:44:45 +01:00

44 lines
1.2 KiB
JavaScript

import { render, screen } from "@testing-library/react-native";
import { PhotoCount } from "components/SharedComponents";
import React from "react";
describe( "PhotoCount", () => {
it( "renders correctly", () => {
render( <PhotoCount count={7} size={50} shadow /> );
expect( screen ).toMatchSnapshot();
} );
describe( "when photo count equal to 0", () => {
it( "should not render", () => {
render( <PhotoCount count={0} /> );
const photoCount = screen.queryByTestId( "photo-count" );
expect( photoCount ).toBeNull();
} );
} );
describe( "when photo count is greater than 0", () => {
describe( "when photo count is greater than 100", () => {
it( "renders photo count value equal to 99", () => {
render( <PhotoCount count={200} /> );
const photoCountValue = screen.getByText( "99" );
expect( photoCountValue ).toBeTruthy();
} );
} );
describe( "when photo count is less than 100", () => {
it( "renders the default photo count value", () => {
render( <PhotoCount count={14} /> );
const photoCountValue = screen.getByText( "14" );
expect( photoCountValue ).toBeTruthy();
} );
} );
} );
} );