react-native-navigation的迁移库

TopLevelApi.test.js 1.9KB

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