set-navigation-bar-color.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  2. const CURRENT_PAGE_PATH = '/pages/API/set-navigation-bar-color/set-navigation-bar-color'
  3. describe('setNavigationBarColor', () => {
  4. if (isAppWebView) {
  5. it('not support', () => {
  6. expect(1).toBe(1)
  7. })
  8. return
  9. }
  10. let page
  11. let originLifeCycleNum
  12. beforeAll(async () => {
  13. page = await program.navigateTo(CURRENT_PAGE_PATH)
  14. await page.waitFor('view')
  15. originLifeCycleNum = await page.callMethod('getLifeCycleNum')
  16. })
  17. afterAll(async () => {
  18. await page.callMethod('setLifeCycleNum', originLifeCycleNum)
  19. const lifeCycleNum = await page.callMethod('getLifeCycleNum')
  20. expect(lifeCycleNum).toBe(originLifeCycleNum)
  21. })
  22. it("setNavigationBarColor1", async () => {
  23. await page.callMethod("setNavigationBarColor1");
  24. const image = await program.screenshot();
  25. expect(image).toSaveImageSnapshot();
  26. const lifeCycleNum = await page.callMethod("getLifeCycleNum");
  27. expect(lifeCycleNum - originLifeCycleNum).toBe(2);
  28. });
  29. it("setNavigationBarColor2", async () => {
  30. await page.callMethod("setNavigationBarColor2");
  31. const image = await program.screenshot();
  32. expect(image).toSaveImageSnapshot();
  33. const lifeCycleNum = await page.callMethod("getLifeCycleNum");
  34. expect(lifeCycleNum - originLifeCycleNum).toBe(4);
  35. });
  36. })