react-native-navigation的迁移库

ScreenStyle.test.js 3.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. const Utils = require('./Utils');
  2. const testIDs = require('../playground/src/testIDs');
  3. const { elementById, elementByLabel } = Utils;
  4. describe('screen style', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. });
  8. it('declare a navigationOptions on container component', async () => {
  9. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  10. await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
  11. });
  12. it('change title on container component', async () => {
  13. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  14. await expect(element(by.label('Static Title').and(by.type('UILabel')))).toBeVisible();
  15. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  16. await expect(element(by.label('Dynamic Title').and(by.type('UILabel')))).toBeVisible();
  17. });
  18. it('set dynamic options with valid options will do something and not crash', async () => {
  19. // we have no way of testing individual styles for the screen
  20. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  21. await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
  22. await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
  23. });
  24. it('hides Tab Bar when pressing on Hide Top Bar and shows it when pressing on Show Top Bar', async () => {
  25. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  26. await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
  27. await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
  28. await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
  29. await expect(element(by.type('UINavigationBar'))).toBeVisible();
  30. });
  31. it('hides topBar onScroll down and shows it on scroll up', async () => {
  32. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  33. await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
  34. await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
  35. await expect(element(by.type('UINavigationBar'))).toBeVisible();
  36. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'fast');
  37. await expect(element(by.type('UINavigationBar'))).toBeNotVisible();
  38. await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
  39. await expect(element(by.type('UINavigationBar'))).toBeVisible();
  40. });
  41. it('makes topBar transparent and opaque', async () => {
  42. await elementByLabel('Push Options Screen').tap();
  43. await elementByLabel('Top Bar Transparent').tap();
  44. await expect(element(by.type('_UIVisualEffectBackdropView'))).toBeNotVisible();
  45. await elementByLabel('Top Bar Opaque').tap();
  46. await expect(element(by.type('_UIVisualEffectBackdropView')).atIndex(1)).toBeVisible();
  47. });
  48. it('set Tab Bar badge on a current Tab', async () => {
  49. await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
  50. await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
  51. await expect(element(by.text('TeSt'))).toBeVisible();
  52. });
  53. it('hide Tab Bar', async () => {
  54. await elementByLabel('Switch to tab based app').tap();
  55. await expect(element(by.type('UITabBar'))).toBeVisible();
  56. await elementByLabel('Hide Tab Bar').tap();
  57. await expect(element(by.type('UITabBar'))).toBeNotVisible();
  58. });
  59. it('show Tab Bar', async () => {
  60. await elementByLabel('Switch to tab based app').tap();
  61. await elementByLabel('Hide Tab Bar').tap();
  62. await expect(element(by.type('UITabBar'))).toBeNotVisible();
  63. await elementByLabel('Show Tab Bar').tap();
  64. await expect(element(by.type('UITabBar'))).toBeVisible();
  65. });
  66. it('set right buttons', async () => {
  67. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  68. await expect(elementById('buttonOne')).toBeVisible();
  69. await elementById('buttonOne').tap();
  70. await expect(elementById('buttonTwo')).toBeVisible();
  71. await elementById('buttonTwo').tap();
  72. await expect(elementById('buttonOne')).toBeVisible();
  73. });
  74. it('set left buttons', async () => {
  75. await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
  76. await expect(elementById('buttonLeft')).toBeVisible();
  77. });
  78. });