react-native-navigation的迁移库

Options.test.js 3.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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('sets right buttons', async () => {
  25. await expect(elementById(TestIDs.BUTTON_ONE)).toBeVisible();
  26. await expect(elementById(TestIDs.ROUND_BUTTON)).toBeVisible();
  27. });
  28. it('set left buttons', async () => {
  29. await expect(elementById(TestIDs.LEFT_BUTTON)).toBeVisible();
  30. });
  31. it('pass props to custom button component', async () => {
  32. await expect(elementByLabel('Two')).toExist();
  33. });
  34. it('pass props to custom button component should exist after push pop', async () => {
  35. await expect(elementByLabel('Two')).toExist();
  36. await elementById(TestIDs.PUSH_BTN).tap();
  37. await elementById(TestIDs.POP_BTN).tap();
  38. await expect(elementByLabel('Two')).toExist();
  39. });
  40. it('custom button is clickable', async () => {
  41. await elementByLabel('Two').tap();
  42. await expect(elementByLabel('Thanks for that :)')).toExist();
  43. });
  44. it('default options should apply to all screens in stack', async () => {
  45. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  46. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  47. await elementById(TestIDs.PUSH_BTN).tap();
  48. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  49. await elementById(TestIDs.PUSH_BTN).tap();
  50. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  51. });
  52. it('default options should not override static options', async () => {
  53. await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
  54. await elementById(TestIDs.PUSH_BTN).tap();
  55. await elementById(TestIDs.POP_BTN).tap();
  56. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  57. await expect(elementByLabel('Styling Options')).toBeVisible();
  58. });
  59. it('set title component', async () => {
  60. await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
  61. await expect(elementByLabel('Press Me')).toBeVisible();
  62. });
  63. it('Popping screen with yellow box should not crash', async () => {
  64. await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
  65. await elementById(TestIDs.PUSH_BTN).tap();
  66. await elementById(TestIDs.POP_BTN).tap();
  67. await expect(elementByLabel('Styling Options')).toBeVisible();
  68. });
  69. xit('hides topBar onScroll down and shows it on scroll up', async () => {
  70. await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
  71. await elementById(TestIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  72. await elementById(TestIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  73. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  74. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
  75. await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
  76. await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  77. await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
  78. });
  79. });