react-native-navigation的迁移库

TopLevelApi.test.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const Utils = require('./Utils');
  2. const elementByLabel = Utils.elementByLabel;
  3. describe('top level api', () => {
  4. beforeEach(async () => {
  5. await device.relaunchApp();
  6. });
  7. it('shows welcome screen', async () => {
  8. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  9. });
  10. it('switch to tab based app, passProps and functions', async () => {
  11. await elementByLabel('Switch to tab based app').tap();
  12. await expect(elementByLabel('This is tab 1')).toBeVisible();
  13. await expect(elementByLabel('Hello from a function!')).toBeVisible();
  14. });
  15. it('switch to tabs with side menus', async () => {
  16. await elementByLabel('Switch to app with side menus').tap();
  17. await elementByLabel('This is a side menu center screen tab 1').swipe('right');
  18. await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
  19. });
  20. it('screen lifecycle', async () => {
  21. await elementByLabel('Push Lifecycle Screen').tap();
  22. await expect(elementByLabel('didAppear')).toBeVisible();
  23. await elementByLabel('Push to test didDisappear').tap();
  24. await expect(elementByLabel('Alert')).toBeVisible();
  25. await expect(elementByLabel('didDisappear')).toBeVisible();
  26. });
  27. it('unmount is called on pop', async () => {
  28. await elementByLabel('Push Lifecycle Screen').tap();
  29. await expect(elementByLabel('didAppear')).toBeVisible();
  30. try {
  31. await element(by.trait(['button']).and(by.label('Back'))).tap();
  32. } catch (err) {
  33. await element(by.type('_UIModernBarButton').and(by.label('Back'))).tap();
  34. }
  35. await expect(elementByLabel('didDisappear')).toBeVisible();
  36. await expect(elementByLabel('componentWillUnmount')).toBeVisible();
  37. });
  38. });
  39. describe('reload app', async () => {
  40. beforeEach(async () => {
  41. await device.relaunchApp();
  42. });
  43. it('push a screen to ensure its not there after reload', async () => {
  44. await elementByLabel('Push').tap();
  45. await expect(elementByLabel('Pushed Screen')).toBeVisible();
  46. await device.reloadReactNative();
  47. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  48. });
  49. });