Skip to content

Commit 7e6b10d

Browse files
committed
android test fix
1 parent 4b6bbfd commit 7e6b10d

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

playground/e2e/Buttons.test.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Platform } from 'react-native';
12
import Utils from './Utils';
23
import 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

Comments
 (0)