react-native-navigation的迁移库

ScreenStack.test.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. describe('screen stack', () => {
  2. beforeEach(async () => {
  3. await device.relaunchApp();
  4. });
  5. it('push and pop screen', async () => {
  6. await elementByLabel('Push').tap();
  7. await expect(elementByLabel('Pushed Screen')).toBeVisible();
  8. await elementByLabel('Pop').tap();
  9. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  10. });
  11. it('pop screen deep in the stack', async () => {
  12. await elementByLabel('Push').tap();
  13. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  14. await elementByLabel('Push').tap();
  15. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  16. await elementByLabel('Pop Previous').tap();
  17. await expect(elementByLabel('Stack Position: 2')).toBeVisible();
  18. await elementByLabel('Pop').tap();
  19. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  20. });
  21. it('pop to specific id', async () => {
  22. await elementByLabel('Push').tap();
  23. await elementByLabel('Push').tap();
  24. await elementByLabel('Push').tap();
  25. await expect(elementByLabel('Stack Position: 3')).toBeVisible();
  26. await elementByLabel('Pop To Stack Position 1').tap();
  27. await expect(elementByLabel('Stack Position: 1')).toBeVisible();
  28. });
  29. it('pop to root', async () => {
  30. await elementByLabel('Push').tap();
  31. await elementByLabel('Push').tap();
  32. await elementByLabel('Push').tap();
  33. await elementByLabel('Pop To Root').tap();
  34. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  35. });
  36. });
  37. function elementByLabel(label) {
  38. return element(by.label(label));
  39. }