react-native-navigation的迁移库

app.test.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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('push screen', () => {
  14. elementByLabel('Push').tap();
  15. expect(elementByLabel('Pushed Screen')).toBeVisible();
  16. });
  17. it('switch to tabs with side menus', () => {
  18. elementByLabel('Switch to app with side menus').tap();
  19. elementByLabel('This is a side menu center screen tab 1').swipe('right');
  20. expect(elementByLabel('This is a left side menu screen')).toBeVisible();
  21. });
  22. it('screen lifecycle', () => {
  23. elementByLabel('Switch to lifecycle screen').tap();
  24. expect(elementByLabel('onStart!')).toBeVisible();
  25. elementByLabel('Push to test onStop').tap();
  26. expect(elementByLabel('Alert')).toBeVisible();
  27. expect(elementByLabel('onStop!')).toBeVisible();
  28. });
  29. it('pop screen', () => {
  30. elementByLabel('Push').tap();
  31. expect(elementByLabel('Pushed Screen')).toBeVisible();
  32. elementByLabel('Pop').tap();
  33. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  34. });
  35. it('show modal', () => {
  36. elementByLabel('Show Modal').tap();
  37. expect(elementByLabel('Modal Screen')).toBeVisible();
  38. });
  39. it('dismiss modal', () => {
  40. elementByLabel('Show Modal').tap();
  41. expect(elementByLabel('Modal Screen')).toBeVisible();
  42. elementByLabel('Dismiss Modal').tap();
  43. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  44. });
  45. it('show multiple modals', () => {
  46. elementByLabel('Show Modal').tap();
  47. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  48. elementByLabel('Show Modal').tap();
  49. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  50. elementByLabel('Dismiss Modal').tap();
  51. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  52. elementByLabel('Dismiss Modal').tap();
  53. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  54. });
  55. it('dismiss unknown screen id', () => {
  56. elementByLabel('Show Modal').tap();
  57. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  58. elementByLabel('Dismiss Unknown Modal').tap();
  59. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  60. elementByLabel('Dismiss Modal').tap();
  61. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  62. });
  63. xit('dismiss modal by id', () => {
  64. elementByLabel('Show Modal').tap();
  65. expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
  66. elementByLabel('Show Modal').tap();
  67. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  68. elementByLabel('Dismiss Previous Modal').tap();
  69. expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
  70. elementByLabel('Dismiss Modal').tap();
  71. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  72. });
  73. });
  74. describe('reload app', () => {
  75. before((done) => {
  76. simulator.reloadReactNativeApp(done);
  77. });
  78. it('shows welcome screen', () => {
  79. expect(elementByLabel('React Native Navigation!')).toBeVisible();
  80. });
  81. });
  82. function elementByLabel(label) {
  83. return element(by.label(label));
  84. }