react-native-navigation的迁移库

ScreenStack.test.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('screen stack', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. it('push and pop screen', async () => {
  9. await elementById(testIDs.PUSH_BUTTON).tap();
  10. await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
  11. await elementById(testIDs.POP_BUTTON).tap();
  12. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  13. });
  14. it('pop screen deep in the stack', async () => {
  15. await elementById(testIDs.PUSH_BUTTON).tap();
  16. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  17. await elementById(testIDs.PUSH_BUTTON).tap();
  18. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  19. await elementById(testIDs.POP_PREVIOUS_BUTTON).tap();
  20. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  21. await elementById(testIDs.POP_BUTTON).tap();
  22. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  23. });
  24. it('pop to specific id', async () => {
  25. await elementById(testIDs.PUSH_BUTTON).tap();
  26. await elementById(testIDs.PUSH_BUTTON).tap();
  27. await elementById(testIDs.PUSH_BUTTON).tap();
  28. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  29. await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
  30. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  31. });
  32. it('pop to root', async () => {
  33. await elementById(testIDs.PUSH_BUTTON).tap();
  34. await elementById(testIDs.PUSH_BUTTON).tap();
  35. await elementById(testIDs.PUSH_BUTTON).tap();
  36. await elementById(testIDs.POP_TO_ROOT).tap();
  37. await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
  38. });
  39. it('switch to tab', async () => {
  40. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  41. await expect(elementByLabel('This is tab 1')).toBeVisible();
  42. await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
  43. await expect(elementByLabel('This is tab 1')).toBeNotVisible();
  44. await expect(elementByLabel('This is tab 2')).toBeVisible();
  45. });
  46. });