mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-19 06:23:12 -04:00
* Use Body3 for username * Add a11y role to user icon * Add a11y matcher to tests * Add snapshot test for normal state * Fix mock user * Rearrange test * Update InlineUser.test.js.snap * Update InlineUser test with i18n init * Update UserIcon.test.js * Replace icon components * Update InlineUser.test.js.snap * Different icon * Update UserIcon.test.js * Update snapshot tests for InlineUser * Update InlineUser.test.js.snap
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
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( "should not have accessibility erros", () => {
|
|
const userIcon = <UserIcon uri={mockUri} />;
|
|
|
|
expect( userIcon ).toBeAccessible();
|
|
} );
|
|
|
|
it( "displays user image correctly", () => {
|
|
render( <UserIcon uri={mockUri} /> );
|
|
|
|
// Snapshot test
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "displays small user image correctly", () => {
|
|
render( <UserIcon uri={mockUri} small /> );
|
|
|
|
// Snapshot test
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "displays active user image correctly", () => {
|
|
render( <UserIcon uri={mockUri} active /> );
|
|
|
|
// Snapshot test
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "shows correct uri for the user icon image", () => {
|
|
render( <UserIcon uri={mockUri} active /> );
|
|
|
|
// TODO: replace with getByRole
|
|
const profilePicture = screen.getByTestId( "UserIcon.photo" );
|
|
expect( profilePicture ).toBeTruthy();
|
|
expect( profilePicture.props.source ).toEqual( mockUri );
|
|
} );
|
|
} );
|