react-native-navigation的迁移库

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const Utils = require('./Utils');
  2. const elementByLabel = Utils.elementByLabel;
  3. describe('modal', () => {
  4. beforeEach(async () => {
  5. await device.relaunchApp();
  6. });
  7. it('show modal', async () => {
  8. await elementByLabel('Show Modal').tap();
  9. await expect(elementByLabel('Modal Screen')).toBeVisible();
  10. });
  11. it('dismiss modal', async () => {
  12. await elementByLabel('Show Modal').tap();
  13. await expect(elementByLabel('Modal Screen')).toBeVisible();
  14. await elementByLabel('Dismiss Modal').tap();
  15. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  16. });
  17. it('show multiple modals', async () => {
  18. await elementByLabel('Show Modal').tap();
  19. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  20. await elementByLabel('Show Modal').tap();
  21. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  22. await elementByLabel('Dismiss Modal').tap();
  23. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  24. await elementByLabel('Dismiss Modal').tap();
  25. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  26. });
  27. it('dismiss unknown screen id', async () => {
  28. await elementByLabel('Show Modal').tap();
  29. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  30. await elementByLabel('Dismiss Unknown Modal').tap();
  31. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  32. await elementByLabel('Dismiss Modal').tap();
  33. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  34. });
  35. it('dismiss modal by id which is not the top most', async () => {
  36. await elementByLabel('Show Modal').tap();
  37. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  38. await elementByLabel('Show Modal').tap();
  39. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  40. await elementByLabel('Dismiss Previous Modal').tap();
  41. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  42. await elementByLabel('Dismiss Modal').tap();
  43. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  44. });
  45. it('dismiss all previous modals by id when they are below top presented modal', async () => {
  46. await elementByLabel('Show Modal').tap();
  47. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  48. await elementByLabel('Show Modal').tap();
  49. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  50. await elementByLabel('Show Modal').tap();
  51. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  52. await elementByLabel('Dismiss ALL Previous Modals').tap();
  53. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  54. await elementByLabel('Dismiss Modal').tap();
  55. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  56. });
  57. it('dismiss some modal by id deep in the stack', async () => {
  58. await elementByLabel('Show Modal').tap();
  59. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  60. await elementByLabel('Show Modal').tap();
  61. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  62. await elementByLabel('Show Modal').tap();
  63. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  64. await elementByLabel('Dismiss First In Stack').tap();
  65. await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  66. await elementByLabel('Dismiss Modal').tap();
  67. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  68. await elementByLabel('Dismiss Modal').tap();
  69. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  70. });
  71. it('dismissAllModals', async () => {
  72. await elementByLabel('Show Modal').tap();
  73. await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  74. await elementByLabel('Show Modal').tap();
  75. await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  76. await elementByLabel('Dismiss All Modals').tap();
  77. await expect(elementByLabel('React Native Navigation!')).toBeVisible();
  78. });
  79. });