react-native-navigation的迁移库

StaticLifecycleEvents.test.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. await elementById(TestIDs.NAVIGATION_TAB).tap();
  8. await elementById(TestIDs.SHOW_STATIC_EVENTS_SCREEN).tap();
  9. await elementById(TestIDs.STATIC_EVENTS_OVERLAY_BTN).tap();
  10. });
  11. it('didAppear didDisappear', async () => {
  12. await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
  13. await elementById(TestIDs.PUSH_BTN).tap();
  14. await expect(elementByLabel('componentDidAppear | Pushed')).toBeVisible();
  15. await expect(elementByLabel('componentDidDisappear | EventsScreen')).toBeVisible();
  16. });
  17. it('pushing and popping screen dispatch static event', async () => {
  18. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  19. await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
  20. await elementById(TestIDs.PUSH_BTN).tap();
  21. await expect(elementByLabel('push')).toBeVisible();
  22. await elementById(TestIDs.POP_BTN).tap();
  23. await expect(elementByLabel('pop')).toBeVisible();
  24. });
  25. it('showModal and dismissModal dispatch static event', async () => {
  26. await elementById(TestIDs.MODAL_BTN).tap();
  27. await expect(elementByLabel('showModal')).toBeVisible();
  28. await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
  29. await expect(elementByLabel('dismissModal')).toBeVisible();
  30. });
  31. it('unmounts when dismissed', async () => {
  32. await elementById(TestIDs.PUSH_BTN).tap();
  33. await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
  34. await elementById(TestIDs.DISMISS_BTN).tap();
  35. await expect(elementByLabel('Overlay Unmounted')).toBeVisible();
  36. await elementByLabel('OK').tap();
  37. });
  38. });