From 84359b8c7fc2dc1c1672a59d11b5e24871bf502c Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Wed, 1 Nov 2023 16:17:02 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BC=98=E5=8C=96=20setNavigationBarCo?= =?UTF-8?q?lor=20=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../set-custom-navigation-bar-color.test.js | 4 ++++ .../set-custom-navigation-bar-color.uvue | 14 +++++++---- .../set-navigation-bar-color.test.js | 24 +++++++++++-------- .../set-navigation-bar-color.uvue | 23 ++++++++---------- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js index 78e2ea17..54cb43f3 100644 --- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js @@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => { area: { x: 880, y: 0, width: 100, height: 60 }, }); expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(2); }); it("setNavigationBarColor1", async () => { @@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => { area: { x: 880, y: 0, width: 100, height: 60 }, }); expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(4); }); }); diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue index dac025f6..5ba29c1c 100644 --- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue @@ -50,12 +50,15 @@ export default { success() { this.navigationBarTextColor = '#fff' console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -66,12 +69,15 @@ export default { success() { this.navigationBarTextColor = '#000' console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js index a293b96b..455947ab 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js @@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => { expect(lifeCycleNum).toBe(originLifeCycleNum) }) - it('setNavigationBarColor1', async () => { - await page.callMethod('setNavigationBarColor1') - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) - it('setNavigationBarColor2', async () => { - await page.callMethod('setNavigationBarColor2') - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) + it("setNavigationBarColor1", async () => { + await page.callMethod("setNavigationBarColor1"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(2); + }); + it("setNavigationBarColor2", async () => { + await page.callMethod("setNavigationBarColor2"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(4); + }); }) diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue index 913daf0a..30efdc46 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue @@ -26,12 +26,15 @@ export default { backgroundColor: '#00ff00', success() { console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -41,12 +44,15 @@ export default { backgroundColor: '#ff0000', success() { console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -66,12 +72,3 @@ export default { }, } - - -- GitLab