Skip to content

Commit

Permalink
Fix more tests in Settings with advanced toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
albullington committed Dec 27, 2024
1 parent fd144d2 commit 2a6024d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unit/components/Settings/Settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jest.mock( "@react-navigation/native", ( ) => {

const initialStoreState = useStore.getState( );

const toggleAdvancedMode = async ( ) => {
const advancedRadioButton = await screen
.findByText( /Advanced/ );
fireEvent.press( advancedRadioButton );
};

beforeAll( async ( ) => {
useStore.setState( initialStoreState, true );
// userEvent recommends fake timers
Expand All @@ -48,6 +54,7 @@ beforeEach( ( ) => {
describe( "Settings", ( ) => {
it( "should toggle the green observation button", async ( ) => {
renderComponent( <Settings /> );
await toggleAdvancedMode( );
const aiCameraRow = await screen.findByLabelText( "iNaturalist AI Camera" );
expect( aiCameraRow ).toHaveProp( "accessibilityState", expect.objectContaining( {
checked: true
Expand All @@ -73,6 +80,7 @@ describe( "Settings", ( ) => {

it( "should toggle taxon names display", async ( ) => {
renderComponent( <Settings /> );
await toggleAdvancedMode( );
const sciNameFirst = await screen.findByLabelText( "Scientific Name (Common Name)" );
expect( sciNameFirst ).toHaveProp( "accessibilityState", expect.objectContaining( {
checked: false
Expand Down Expand Up @@ -110,6 +118,7 @@ describe( "Settings", ( ) => {

it( "should not change state if taxon names toggled with no internet", async ( ) => {
renderComponent( <Settings /> );
await toggleAdvancedMode( );
const sciNameFirst = await screen.findByLabelText( "Scientific Name (Common Name)" );
expect( sciNameFirst ).toHaveProp( "accessibilityState", expect.objectContaining( {
checked: false
Expand All @@ -135,6 +144,7 @@ describe( "Settings", ( ) => {

test( "should change language immediately via language picker via online results", async ( ) => {
renderComponent( <Settings /> );
await toggleAdvancedMode( );
const changeLanguageButton = await screen.findByText( /CHANGE APP LANGUAGE/ );
fireEvent.press( changeLanguageButton );
const picker = await screen.findByTestId( "ReactNativePicker" );
Expand Down

0 comments on commit 2a6024d

Please sign in to comment.