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

test(component lifecycle): 优化示例,兼容 web 端

上级 fb22177e
<template>
<view>
<text>{{ title }}</text>
</view>
title: {{ title }}
<button class="component-lifecycle-btn" @click="updateTitle">updateTitle</button>
</template>
<script lang="ts">
......@@ -54,10 +53,9 @@ export default {
console.log('component for lifecycle test unmounted')
},
methods: {
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
updateTitle(){
this.title = 'component for lifecycle test updated'
}
},
}
</script>
......@@ -76,7 +76,7 @@
})
this.myGlobalProperties.map = {}
this.globalPropertiesMap.forEach((value, key) => {
this.myGlobalProperties.map[key!] = value
this.myGlobalProperties.map[key] = value
})
this.myGlobalProperties.reactiveObj = this.globalPropertiesReactiveObj
this.globalPropertiesFnRes = this.globalPropertiesFn()
......
......@@ -27,23 +27,14 @@ describe('component-lifecycle', () => {
expect(lifeCycleNum).toBe(4)
})
it('beforeUpdate updated', async () => {
// TODO: web 端组件更新不触发 updated,待修复后调整测试例
if (process.env.uniTestPlatformInfo.startsWith('android')) {
const component = await page.$('.component-lifecycle')
await component.setData({
title: 'component for lifecycle test new title'
})
const updateTitleBtn = await page.$('.component-lifecycle-btn')
await updateTitleBtn.tap()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(6)
}
})
it('beforeUnmount unmounted', async () => {
page = await program.navigateBack()
lifeCycleNum = await page.callMethod('getLifeCycleNum')
if (process.env.uniTestPlatformInfo.startsWith('android')) {
expect(lifeCycleNum).toBe(4)
}else{
expect(lifeCycleNum).toBe(2)
}
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册