react-native-navigation的迁移库

Options.test.js 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  56. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  57. await elementById(TestIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  58. await elementById(TestIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  59. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  60. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  61. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  62. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  63. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  64. });
  65. });