mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 14:08:31 -04:00
* Add font weight to Typography elements
* Add Heading5
* Typography snapshot tests
* Add letterSpacing to Heading 4 and 5
* Update Button padding
* Update Button styling
* Add rounded-lg
* Code style and comments
* Add button tests
* Added loading state color to buttons
* Add default color to text
* Use text class name instead
* Change text
* Add non default color text
* Snapshot for icon
* Default text color into button snap
* Update INatIcon.js
* Add Divider component
* Updates to Tabs UI
* Update color
* Add Divider test
* Show underline only when active
* Tabs snapshot
* Update Button UI
* Revert "Update Button UI"
This reverts commit 5361f57dac.
* Update ActivityCount.js
* Get color from theme in buttons
* Use translated string for hints in Tabs snapshots
* Refactor fct args
* Update Tabs
* Remove async
* Use .each in Button test
* Remove comment
* Structuring
* Remove duplicate application of style defaults
* Remove async from Typography
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
import { Tabs } from "components/SharedComponents";
|
|
import initI18next from "i18n/initI18next";
|
|
import React from "react";
|
|
|
|
const TAB_1 = "TAB_1";
|
|
const TAB_2 = "TAB_2";
|
|
const tab1Click = jest.fn();
|
|
const tab2Click = jest.fn();
|
|
|
|
const tabs = [
|
|
{
|
|
id: TAB_1,
|
|
text: TAB_1,
|
|
onPress: tab1Click
|
|
},
|
|
{
|
|
id: TAB_2,
|
|
text: TAB_2,
|
|
onPress: tab2Click
|
|
}
|
|
];
|
|
|
|
describe( "Tabs", () => {
|
|
beforeAll( async () => {
|
|
await initI18next();
|
|
} );
|
|
|
|
it( "should render correctly", () => {
|
|
render( <Tabs tabs={tabs} activeId={TAB_1} /> );
|
|
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "should not have accessibility errors", () => {
|
|
const tabComp = <Tabs tabs={tabs} activeId={TAB_1} />;
|
|
|
|
expect( tabComp ).toBeAccessible();
|
|
} );
|
|
|
|
it( "should be clicked and display proper text", async () => {
|
|
render( <Tabs tabs={tabs} activeId={TAB_1} /> );
|
|
const tab1 = await screen.findByLabelText( TAB_1 );
|
|
const tab2 = await screen.findByLabelText( TAB_2 );
|
|
|
|
expect( tab1 ).toBeTruthy();
|
|
expect( tab2 ).toBeTruthy();
|
|
expect( tab1 ).toHaveAccessibilityState( { selected: true, expanded: true } );
|
|
expect( tab2 ).toHaveAccessibilityState( { selected: false, expanded: false } );
|
|
|
|
fireEvent.press( tab2 );
|
|
expect( tab1Click ).not.toHaveBeenCalled();
|
|
expect( tab2Click ).toHaveBeenCalled();
|
|
} );
|
|
} );
|