react-native-navigation的迁移库

TopLevelApi.test.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. it('shows welcome screen', async () => {
  9. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  10. });
  11. it('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. it('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. it('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('Alert')).toBeVisible();
  26. await expect(elementByLabel('didDisappear')).toBeVisible();
  27. });
  28. it('unmount is called on pop', async () => {
  29. await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
  30. await expect(elementByLabel('didAppear')).toBeVisible();
  31. await elementById(testIDs.POP_BUTTON).tap();
  32. await expect(elementByLabel('componentWillUnmount')).toBeVisible();
  33. await elementByLabel('OK').atIndex(0).tap();
  34. await expect(elementByLabel('didDisappear')).toBeVisible();
  35. });
  36. });
  37. describe('reload app', async () => {
  38. beforeEach(async () => {
  39. await device.relaunchApp();
  40. });
  41. it('push a screen to ensure its not there after reload', async () => {
  42. await elementById(testIDs.PUSH_BUTTON).tap();
  43. await expect(elementByLabel('Pushed Screen')).toBeVisible();
  44. await device.reloadReactNative();
  45. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  46. });
  47. });