提交 84359b8c 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化 setNavigationBarColor 测试例

上级 e9385585
...@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => { ...@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 }, area: { x: 880, y: 0, width: 100, height: 60 },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
}); });
it("setNavigationBarColor1", async () => { it("setNavigationBarColor1", async () => {
...@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => { ...@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 }, area: { x: 880, y: 0, width: 100, height: 60 },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
}); });
}); });
...@@ -50,12 +50,15 @@ export default { ...@@ -50,12 +50,15 @@ export default {
success() { success() {
this.navigationBarTextColor = '#fff' this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -66,12 +69,15 @@ export default { ...@@ -66,12 +69,15 @@ export default {
success() { success() {
this.navigationBarTextColor = '#000' this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
......
...@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => { ...@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => {
expect(lifeCycleNum).toBe(originLifeCycleNum) expect(lifeCycleNum).toBe(originLifeCycleNum)
}) })
it('setNavigationBarColor1', async () => { it("setNavigationBarColor1", async () => {
await page.callMethod('setNavigationBarColor1') await page.callMethod("setNavigationBarColor1");
const image = await program.screenshot() const image = await program.screenshot();
expect(image).toMatchImageSnapshot() expect(image).toMatchImageSnapshot();
}) const lifeCycleNum = await page.callMethod("getLifeCycleNum");
it('setNavigationBarColor2', async () => { expect(lifeCycleNum - originLifeCycleNum).toBe(2);
await page.callMethod('setNavigationBarColor2') });
const image = await program.screenshot() it("setNavigationBarColor2", async () => {
expect(image).toMatchImageSnapshot() await page.callMethod("setNavigationBarColor2");
}) const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
});
}) })
...@@ -26,12 +26,15 @@ export default { ...@@ -26,12 +26,15 @@ export default {
backgroundColor: '#00ff00', backgroundColor: '#00ff00',
success() { success() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -41,12 +44,15 @@ export default { ...@@ -41,12 +44,15 @@ export default {
backgroundColor: '#ff0000', backgroundColor: '#ff0000',
success() { success() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -66,12 +72,3 @@ export default { ...@@ -66,12 +72,3 @@ export default {
}, },
} }
</script> </script>
<style>
.direction-row {
flex-direction: row;
}
.label {
width: 190px;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册