react-native-navigation的迁移库

BottomTabs.test.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const Utils = require('./Utils');
  2. const TestIDs = require('../playground/src/testIDs');
  3. const Android = require('./AndroidUtils');
  4. const { elementByLabel, elementById, sleep } = Utils;
  5. describe('BottomTabs', () => {
  6. beforeEach(async () => {
  7. await device.relaunchApp();
  8. await elementById(TestIDs.BOTTOM_TABS_BTN).tap();
  9. await expect(elementByLabel('First Tab')).toBeVisible();
  10. });
  11. it('switch to tab by index', async () => {
  12. await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
  13. await expect(elementByLabel('First Tab')).toBeNotVisible();
  14. await expect(elementByLabel('Second Tab')).toBeVisible();
  15. });
  16. it('switch to tab by componentId', async () => {
  17. await elementById(TestIDs.SWITCH_TAB_BY_COMPONENT_ID_BTN).tap();
  18. await expect(elementByLabel('First Tab')).toBeNotVisible();
  19. await expect(elementByLabel('Second Tab')).toBeVisible();
  20. });
  21. it('push bottom tabs', async () => {
  22. await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
  23. await elementById(TestIDs.PUSH_BTN).tap();
  24. await expect(elementById(TestIDs.PUSHED_BOTTOM_TABS)).toBeVisible();
  25. });
  26. it('set Tab Bar badge on current Tab', async () => {
  27. await elementById(TestIDs.SET_BADGE_BTN).tap();
  28. await expect(element(by.text('NEW'))).toBeVisible();
  29. });
  30. it('set empty string badge on a current Tab should clear badge', async () => {
  31. await elementById(TestIDs.SET_BADGE_BTN).tap();
  32. await expect(element(by.text('NEW'))).toBeVisible();
  33. await elementById(TestIDs.CLEAR_BADGE_BTN).tap();
  34. await expect(element(by.text('NEW'))).toBeNotVisible();
  35. });
  36. it('merge options correctly in SideMenu inside BottomTabs layout', async () => {
  37. await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
  38. await elementById(TestIDs.SIDE_MENU_INSIDE_BOTTOM_TABS_BTN).tap();
  39. await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
  40. await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
  41. await expect(elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN)).toBeNotVisible();
  42. });
  43. it(':android: hide Tab Bar', async () => {
  44. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
  45. await elementById(TestIDs.HIDE_TABS_BTN).tap();
  46. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
  47. });
  48. it(':android: show Tab Bar', async () => {
  49. await elementById(TestIDs.HIDE_TABS_BTN).tap();
  50. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
  51. await elementById(TestIDs.SHOW_TABS_BTN).tap();
  52. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
  53. });
  54. it('hide Tab Bar on push', async () => {
  55. await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
  56. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
  57. await elementById(TestIDs.POP_BTN).tap();
  58. await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
  59. });
  60. });