1+ import { Platform } from 'react-native' ;
12import Utils from './Utils' ;
23import TestIDs from '../src/testIDs' ;
34
@@ -22,14 +23,21 @@ describe('Buttons', () => {
2223 } ) ;
2324
2425 it ( ':android: should not effect left buttons when hiding back button' , async ( ) => {
25- await elementById ( TestIDs . TOGGLE_BACK ) . tap ( ) ;
26- await expect ( elementById ( TestIDs . LEFT_BUTTON ) ) . toBeVisible ( ) ;
27- await expect ( elementById ( TestIDs . TEXTUAL_LEFT_BUTTON ) ) . toBeVisible ( ) ;
28- await expect ( elementById ( TestIDs . BACK_BUTTON ) ) . toBeVisible ( ) ;
29-
30- await elementById ( TestIDs . TOGGLE_BACK ) . tap ( ) ;
31- await expect ( elementById ( TestIDs . LEFT_BUTTON ) ) . toBeVisible ( ) ;
32- await expect ( elementById ( TestIDs . TEXTUAL_LEFT_BUTTON ) ) . toBeVisible ( ) ;
26+ // Jest mock runs with Platform.OS === 'ios'; this test asserts Android-only topBar behavior.
27+ const platform = Platform . OS ;
28+ Platform . OS = 'android' ;
29+ try {
30+ await elementById ( TestIDs . TOGGLE_BACK ) . tap ( ) ;
31+ await expect ( elementById ( TestIDs . LEFT_BUTTON ) ) . toBeVisible ( ) ;
32+ await expect ( elementById ( TestIDs . TEXTUAL_LEFT_BUTTON ) ) . toBeVisible ( ) ;
33+ await expect ( elementById ( TestIDs . BACK_BUTTON ) ) . toBeVisible ( ) ;
34+
35+ await elementById ( TestIDs . TOGGLE_BACK ) . tap ( ) ;
36+ await expect ( elementById ( TestIDs . LEFT_BUTTON ) ) . toBeVisible ( ) ;
37+ await expect ( elementById ( TestIDs . TEXTUAL_LEFT_BUTTON ) ) . toBeVisible ( ) ;
38+ } finally {
39+ Platform . OS = platform ;
40+ }
3341 } ) ;
3442 it ( 'sets right buttons' , async ( ) => {
3543 await expect ( elementById ( TestIDs . BUTTON_ONE ) ) . toBeVisible ( ) ;
0 commit comments