react-native-navigation的迁移库

Modals.test.js 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. });