react-native-navigation的迁移库

StaticLifecycleEvents.test.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementByLabel, elementById } = Utils;
  4. describe('static lifecycle events', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. test('didAppear didDisappear', async () => {
  9. await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
  10. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  11. await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
  12. await elementById(testIDs.PUSH_BUTTON).tap();
  13. await expect(elementByLabel('componentDidAppear | navigation.playground.PushedScreen')).toBeVisible();
  14. await expect(elementByLabel('componentDidDisappear | navigation.playground.WelcomeScreen')).toBeVisible();
  15. });
  16. test(':ios: pushing and popping screen dispatch static event', async () => {
  17. await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
  18. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  19. await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
  20. await elementById(testIDs.PUSH_BUTTON).tap();
  21. await expect(elementByLabel('push')).toBeVisible();
  22. await elementById(testIDs.POP_BUTTON).tap();
  23. await expect(elementByLabel('pop')).toBeVisible();
  24. });
  25. test(':ios: showModal and dismissModal dispatch static event', async () => {
  26. await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
  27. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  28. await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
  29. await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
  30. await expect(elementByLabel('showModal')).toBeVisible();
  31. await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
  32. await expect(elementByLabel('dismissModal')).toBeVisible();
  33. });
  34. test(':ios: unmounts when dismissed', async () => {
  35. await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
  36. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  37. await elementById(testIDs.DISMISS_BUTTON).tap();
  38. await expect(elementByLabel('Overlay Unmounted')).toBeVisible();
  39. await elementByLabel('OK').tap();
  40. });
  41. });