react-native-navigation的迁移库

Modals.test.js 4.0KB

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