Files
iNaturalistReactNative/tests/unit/components/SharedComponents/UserIcon/UserIcon.test.js
Johannes Klein e57aac93f6 418 create an index.js file for importing shared components (#427)
* Update .eslintrc.js

* Create index.js

* Change Button usage in GridItem

* Replace imports

* Add strings

* Add hint prop to button

* Add a11y hint prop to EvidenceButton

* Add EvidenceButton to index

* Add a11y props to EvidenceButton

* Update UiLibrary.js

* Add a11y props to CloseButton

* Add CloseButton to index and UiLib

* Rename function

* Update string

* Add a11y props to AddObsButton

* Add Tabs to index

* Linebreak

* Add Typography to index

* Remove unused text

* Refactor UserIcon test coverage in it's own test

* Add UserIcon to index

* Add UserIcon to UiLib

* Add InlineUser to index

* Add Quality badge to index

* Update UiLibrary.js

* Remove unused component

* Change AddObsButton a11y label

* Change hint

* Use consistent uri in snapshots

* Add snapshot to InlineUser

* Fix wrong user key

* Update Tabs.test.js

* Snapshot TODO

* Update NavButton.js

* Update snapshot

* Add snapshot for active user icon

* Remove snapshot result

* Add ActivityCount to index

* Update UiLibrary.js
2023-02-04 15:18:42 +01:00

34 lines
951 B
JavaScript

import { render, screen } from "@testing-library/react-native";
import { UserIcon } from "components/SharedComponents";
import React from "react";
const mockUri = { uri: "some_uri" };
describe( "UserIcon", () => {
it( "displays user image correctly", async () => {
render( <UserIcon uri={mockUri} /> );
// Check for image source
const profilePicture = await screen.findByTestId( "UserIcon.photo" );
expect( profilePicture ).toBeTruthy();
expect( profilePicture.props.source ).toEqual( mockUri );
// Snapshot test
expect( screen ).toMatchSnapshot();
} );
it( "displays small user image correctly", async () => {
render( <UserIcon uri={mockUri} small /> );
// Snapshot test
expect( screen ).toMatchSnapshot();
} );
it( "displays active user image correctly", async () => {
render( <UserIcon uri={mockUri} active /> );
// Snapshot test
expect( screen ).toMatchSnapshot();
} );
} );