react-native-navigation的迁移库

TopLevelApi.test.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('top level api', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. test('shows welcome screen', async () => {
  9. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  10. });
  11. test('switch to tab based app, passProps and functions', async () => {
  12. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  13. await expect(elementByLabel('This is tab 1')).toBeVisible();
  14. await expect(elementByLabel('Hello from a function!')).toBeVisible();
  15. });
  16. test(':ios: switch to tabs with side menus', async () => {
  17. await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
  18. await elementById(testIDs.CENTERED_TEXT_HEADER).swipe('right');
  19. await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
  20. });
  21. test('screen lifecycle', async () => {
  22. await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
  23. await expect(elementByLabel('didAppear')).toBeVisible();
  24. await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
  25. await expect(elementByLabel('didDisappear')).toBeVisible();
  26. });
  27. test('unmount is called on pop', async () => {
  28. await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
  29. await expect(elementByLabel('didAppear')).toBeVisible();
  30. await elementById(testIDs.POP_BUTTON).tap();
  31. await expect(elementByLabel('componentWillUnmount')).toBeVisible();
  32. await elementByLabel('OK').atIndex(0).tap();
  33. await expect(elementByLabel('didDisappear')).toBeVisible();
  34. });
  35. });