react-native-navigation的迁移库

ScreenStyle.test.js 3.8KB

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