react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. const Utils = require('./Utils');
  2. const Android = require('./AndroidUtils');
  3. const TestIDs = require('../playground/src/testIDs');
  4. const { elementById, elementByLabel } = Utils;
  5. describe('Options', () => {
  6. beforeEach(async () => {
  7. await device.relaunchApp();
  8. await elementById(TestIDs.OPTIONS_TAB).tap();
  9. });
  10. it('declare options on a component', async () => {
  11. await expect(elementByLabel('Styling Options')).toBeVisible();
  12. });
  13. it('change title on component component', async () => {
  14. await expect(elementByLabel('Styling Options')).toBeVisible();
  15. await elementById(TestIDs.CHANGE_TITLE_BTN).tap();
  16. await expect(elementByLabel('Title Changed')).toBeVisible();
  17. });
  18. it('hides TopBar when pressing on Hide TopBar and shows it when pressing on Show TopBar', async () => {
  19. await elementById(TestIDs.HIDE_TOP_BAR_BTN).tap();
  20. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  21. await elementById(TestIDs.SHOW_TOP_BAR_BTN).tap();
  22. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  23. });
  24. it('default options should apply to all screens in stack', async () => {
  25. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  26. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  27. await elementById(TestIDs.PUSH_BTN).tap();
  28. await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeNotVisible();
  29. await elementById(TestIDs.PUSH_BTN).tap();
  30. await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeNotVisible();
  31. });
  32. it('default options should not override static options', async () => {
  33. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  34. await elementById(TestIDs.PUSH_BTN).tap();
  35. await elementById(TestIDs.POP_BTN).tap();
  36. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  37. await expect(elementByLabel('Styling Options')).toBeVisible();
  38. });
  39. it('set title component', async () => {
  40. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  41. await expect(elementByLabel('Press Me')).toBeVisible();
  42. });
  43. it('set title after setting react component', async () => {
  44. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  45. await expect(elementByLabel('Press Me')).toBeVisible();
  46. await elementById(TestIDs.CHANGE_TITLE_BTN).tap();
  47. await expect(elementByLabel('Title Changed')).toBeVisible();
  48. });
  49. it('Popping screen with yellow box should not crash', async () => {
  50. await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
  51. await elementById(TestIDs.PUSH_BTN).tap();
  52. await elementById(TestIDs.POP_BTN).tap();
  53. await expect(elementByLabel('Styling Options')).toBeVisible();
  54. });
  55. it('Merging options to invisible component in stack should not affect current component', async () => {
  56. await elementById(TestIDs.PUSH_BTN).tap();
  57. await elementById(TestIDs.HIDE_PREVIOUS_SCREEN_TOP_BAR).tap();
  58. await expect(elementByLabel('Pushed Screen')).toBeVisible();
  59. });
  60. it('Merging options to invisible component should affect the invisible component', async () => {
  61. await elementById(TestIDs.PUSH_BTN).tap();
  62. await elementById(TestIDs.HIDE_PREVIOUS_SCREEN_TOP_BAR).tap();
  63. await elementById(TestIDs.POP_BTN).tap();
  64. await expect(elementByLabel('Styling Options')).toBeNotVisible();
  65. });
  66. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  67. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  68. await elementById(TestIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  69. await elementById(TestIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  70. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  71. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  72. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  73. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  74. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  75. });
  76. });