react-native-navigation的迁移库

ScreenStack.test.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const Utils = require('./Utils');
  2. const elementByLabel = Utils.elementByLabel;
  3. describe('screen stack', () => {
  4. beforeEach(async () => {
  5. await device.relaunchApp();
  6. });
  7. it('push and pop screen', async () => {
  8. await elementByLabel('Push').tap();
  9. await expect(elementByLabel('Pushed Screen')).toBeVisible();
  10. await elementByLabel('Pop').tap();
  11. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  12. });
  13. it('pop screen deep in the stack', async () => {
  14. await elementByLabel('Push').tap();
  15. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  16. await elementByLabel('Push').tap();
  17. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  18. await elementByLabel('Pop Previous').tap();
  19. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  20. await elementByLabel('Pop').tap();
  21. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  22. });
  23. it('pop to specific id', async () => {
  24. await elementByLabel('Push').tap();
  25. await elementByLabel('Push').tap();
  26. await elementByLabel('Push').tap();
  27. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  28. await elementByLabel('Pop To Stack Position 1').tap();
  29. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  30. });
  31. it('pop to root', async () => {
  32. await elementByLabel('Push').tap();
  33. await elementByLabel('Push').tap();
  34. await elementByLabel('Push').tap();
  35. await elementByLabel('Pop To Root').tap();
  36. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  37. });
  38. it('switch to tab', async () => {
  39. await elementByLabel('Switch to tab based app').tap();
  40. await expect(elementByLabel('This is tab 1')).toBeVisible();
  41. await elementByLabel('Switch To Tab 2').tap();
  42. await expect(elementByLabel('This is tab 1')).toBeNotVisible();
  43. await expect(elementByLabel('This is tab 2')).toBeVisible();
  44. });
  45. });