react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. describe('app', () => {
  2. beforeEach((done) => {
  3. global.simulator.relaunchApp(done);
  4. });
  5. it('shows welcome screen', () => {
  6. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  7. });
  8. it('switch to tab based app, passProps and functions', () => {
  9. elementByLabel('Switch to tab based app').tap();
  10. expect(elementByLabel('This is tab 1')).toBeVisible();
  11. expect(elementByLabel('Hello from a function!')).toBeVisible();
  12. });
  13. it('switch to tabs with side menus', () => {
  14. elementByLabel('Switch to app with side menus').tap();
  15. elementByLabel('This is a side menu center screen tab 1').swipe('right');
  16. expect(elementByLabel('This is a left side menu screen')).toBeVisible();
  17. });
  18. it('screen lifecycle', () => {
  19. elementByLabel('Switch to lifecycle screen').tap();
  20. expect(elementByLabel('onStart!')).toBeVisible();
  21. elementByLabel('Push to test onStop').tap();
  22. expect(elementByLabel('Alert')).toBeVisible();
  23. expect(elementByLabel('onStop!')).toBeVisible();
  24. });
  25. });
  26. describe('screen stack', () => {
  27. beforeEach((done) => {
  28. global.simulator.relaunchApp(done);
  29. });
  30. it('push screen', () => {
  31. elementByLabel('Push').tap();
  32. expect(elementByLabel('Pushed Screen')).toBeVisible();
  33. });
  34. it('pop screen', () => {
  35. elementByLabel('Push').tap();
  36. expect(elementByLabel('Pushed Screen')).toBeVisible();
  37. elementByLabel('Pop').tap();
  38. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  39. });
  40. it('pop screen deep in the stack', () => {
  41. elementByLabel('Push').tap();
  42. expect(elementByLabel('Stack Position: 1')).toBeVisible();
  43. elementByLabel('Push').tap();
  44. expect(elementByLabel('Stack Position: 2')).toBeVisible();
  45. elementByLabel('Pop Previous').tap();
  46. expect(elementByLabel('Stack Position: 2')).toBeVisible();
  47. elementByLabel('Pop').tap();
  48. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  49. });
  50. });
  51. describe('modal', () => {
  52. beforeEach((done) => {
  53. global.simulator.relaunchApp(done);
  54. });
  55. it('show modal', () => {
  56. elementByLabel('Show Modal').tap();
  57. expect(elementByLabel('Modal Screen')).toBeVisible();
  58. });
  59. it('dismiss modal', () => {
  60. elementByLabel('Show Modal').tap();
  61. expect(elementByLabel('Modal Screen')).toBeVisible();
  62. elementByLabel('Dismiss Modal').tap();
  63. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  64. });
  65. it('show multiple modals', () => {
  66. elementByLabel('Show Modal').tap();
  67. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  68. elementByLabel('Show Modal').tap();
  69. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  70. elementByLabel('Dismiss Modal').tap();
  71. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  72. elementByLabel('Dismiss Modal').tap();
  73. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  74. });
  75. it('dismiss unknown screen id', () => {
  76. elementByLabel('Show Modal').tap();
  77. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  78. elementByLabel('Dismiss Unknown Modal').tap();
  79. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  80. elementByLabel('Dismiss Modal').tap();
  81. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  82. });
  83. it('dismiss modal by id which is not the top most', () => {
  84. elementByLabel('Show Modal').tap();
  85. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  86. elementByLabel('Show Modal').tap();
  87. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  88. elementByLabel('Dismiss Previous Modal').tap();
  89. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  90. elementByLabel('Dismiss Modal').tap();
  91. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  92. });
  93. it('dismiss all previous modals by id when they are below top presented modal', () => {
  94. elementByLabel('Show Modal').tap();
  95. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  96. elementByLabel('Show Modal').tap();
  97. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  98. elementByLabel('Show Modal').tap();
  99. expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  100. elementByLabel('Dismiss ALL Previous Modals').tap();
  101. expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  102. elementByLabel('Dismiss Modal').tap();
  103. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  104. });
  105. it('dismiss some modal by id deep in the stack', () => {
  106. elementByLabel('Show Modal').tap();
  107. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  108. elementByLabel('Show Modal').tap();
  109. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  110. elementByLabel('Show Modal').tap();
  111. expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  112. elementByLabel('Dismiss First In Stack').tap();
  113. expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
  114. elementByLabel('Dismiss Modal').tap();
  115. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  116. elementByLabel('Dismiss Modal').tap();
  117. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  118. });
  119. it('dismissAllModals', () => {
  120. elementByLabel('Show Modal').tap();
  121. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  122. elementByLabel('Show Modal').tap();
  123. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  124. elementByLabel('Dismiss All Modals').tap();
  125. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  126. });
  127. });
  128. describe('reload app', () => {
  129. before((done) => {
  130. simulator.reloadReactNativeApp(done);
  131. });
  132. it('shows welcome screen', () => {
  133. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  134. });
  135. });
  136. function elementByLabel(label) {
  137. return element(by.label(label));
  138. }