提交 67a29088 编写于 作者: VK1688's avatar VK1688

补充open-location.test.js

上级 b9dda4c5
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const isIos = platformInfo.startsWith('ios')
describe('dialog page', () => {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('skip app-webview', () => {
expect(1).toBe(1)
})
return
}
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page;
let originLifeCycleNum;
beforeAll(async () => {
page = await program.reLaunch('/pages/API/open-location/open-location')
await page.waitFor('view');
originLifeCycleNum = await page.callMethod('getLifeCycleNum')
await page.callMethod('openLocation')
await page.waitFor(1000)
});
it('dialogPage should empty', async () => {
const dialogPagesNum = await page.data('dialogPagesNum')
expect(dialogPagesNum).toBe(0)
})
it('should trigger parent hide', async () => {
const lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(originLifeCycleNum - 1)
})
if (isIos) {
// 15以下的模拟器所对应的xcode不能编译自定义插件,大于15是因为某台设备,会用xcode14.1跑15.5的设备
let version = process.env.uniTestPlatformInfo
let split = version.split(" ")
version = parseInt(split[split.length - 1])
if (version > 15) {
it('call openLocation in uts plugin', async () => {
page = await program.reLaunch('/pages/API/open-location/open-location')
await page.waitFor('view');
await page.callMethod('openLocationByPlugin')
await page.waitFor(1000)
const lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(originLifeCycleNum - 1)
})
}
}
afterAll(async () => {
await page.callMethod('setLifeCycleNum', originLifeCycleNum)
});
})
......@@ -47,7 +47,12 @@
</view>
</view>
</template>
<script lang="uts">
<script lang="uts">
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
export default {
data() {
return {
......@@ -55,11 +60,20 @@
longitude: 116.39747,
latitude: 39.9085,
name: '天安门',
address: '北京市东城区东长安街'
address: '北京市东城区东长安街',
// 自动化测试
dialogPagesNum: -1,
}
},
onHide() {
console.log("Page Hide");
},
onShow() {
console.log("Page Show");
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
onHide() {
console.log("Page Hide");
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1)
},
methods: {
openLocation: function () {
......@@ -68,8 +82,29 @@
latitude: this.latitude,
name: this.name,
address: this.address
})
}
})
// 自动化测试
setTimeout(() => {
this.test()
}, 500)
},
// 自动化测试
test() {
const pages = getCurrentPages()
const page = pages[pages.length - 1]
// #ifdef APP || WEB
const dialogPages = page.getDialogPages()
this.dialogPagesNum = dialogPages.length
// #endif
},
// 自动化测试
setLifeCycleNum(value : number) {
setLifeCycleNum(value)
},
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册