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

test(KeepAlive): 补充生命周期测试

上级 f4154337
<template>
<view>
<text class="counter-text">count: {{ count }}</text>
<text class="uni-common-mt counter-btn" @click="increment"></text>
<text class="uni-common-mt counter-btn" @click="increment"></text>
<text class="uni-common-mt" id="activated-num">activated num: {{ activatedNum }}</text>
<text class="uni-common-mt" id="deactivated-num">deactivated num: {{ deactivatedNum }}</text>
</view>
</template>
......@@ -10,9 +12,13 @@
name: 'Counter',
data() {
return {
count: 0
count: 0,
activatedNum: 0,
deactivatedNum: 0,
}
},
activated() { this.activatedNum++ },
deactivated() { this.deactivatedNum++ },
methods: {
increment() {
this.count++
......@@ -29,4 +35,4 @@
border-radius: 4px;
text-align: center;
}
</style>
</style>
\ No newline at end of file
......@@ -18,6 +18,11 @@ describe('keep-alive', () => {
const showCounterBtn = await page.$('.show-counter')
await showCounterBtn.tap()
const activatedNum = await page.$('#activated-num')
expect(await activatedNum.text()).toBe('activated num: 1')
const deactivatedNum = await page.$('#deactivated-num')
expect(await deactivatedNum.text()).toBe('deactivated num: 0')
const counterBtns = await page.$$('.counter-btn')
for (let i = 0; i < counterBtns.length; i++) {
......@@ -38,6 +43,9 @@ describe('keep-alive', () => {
await showCounterBtn.tap()
expect(await activatedNum.text()).toBe('activated num: 2')
expect(await deactivatedNum.text()).toBe('deactivated num: 1')
let counterTexts = await page.$$('.counter-text')
for (let i = 0; i < counterTexts.length; i++) {
expect(await counterTexts[i].text()).toBe('count: 1')
......@@ -58,6 +66,9 @@ describe('keep-alive', () => {
await showCounterBtn.tap()
expect(await activatedNum.text()).toBe('activated num: 3')
expect(await deactivatedNum.text()).toBe('deactivated num: 2')
counterTexts = await page.$$('.counter-text')
for (let i = 0; i < counterTexts.length; i++) {
expect(await counterTexts[i].text()).toBe('count: 1')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册