react-native-navigation的迁移库

StaticLifecycleEvents.test.js 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 | Component')).toBeVisible();
  13. await elementById(TestIDs.PUSH_BTN).tap();
  14. await expect(elementByLabel('componentDidAppear | Pushed | Component')).toBeVisible();
  15. await expect(elementByLabel('componentDidDisappear | EventsScreen | Component')).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 | Component')).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. it('top bar buttons didAppear didDisappear', async () => {
  39. await elementById(TestIDs.PUSH_BTN).tap();
  40. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  41. await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
  42. await elementById(TestIDs.GOTO_BUTTONS_SCREEN).tap();
  43. await expect(elementByLabel('componentDidAppear | CustomRoundedButton | TopBarButton')).toBeVisible();
  44. await elementById(TestIDs.RESET_BUTTONS).tap();
  45. await expect(elementByLabel('componentDidDisappear | CustomRoundedButton | TopBarButton')).toBeVisible();
  46. });
  47. it('top bar title didAppear didDisappear', async () => {
  48. await elementById(TestIDs.PUSH_BTN).tap();
  49. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  50. await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
  51. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  52. await expect(elementByLabel('componentDidAppear | ReactTitleView | TopBarTitle')).toBeVisible();
  53. await elementById(TestIDs.PUSH_BTN).tap();
  54. await expect(elementByLabel('componentDidDisappear | ReactTitleView | TopBarTitle')).toBeVisible();
  55. });
  56. });