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

refactor(dialogPage): 移除 eventBus

上级 ba2be59b
......@@ -55,14 +55,6 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
dialogPage.emit('fn1', { from: 'dialog1' })
dialogPage.emit('fn2', null)
dialogPage.off('fn2', null)
dialogPage.emit('fn1', { from: 'dialog1' })
dialogPage.emit('fn2', null)
dialogPage.emit('fnOnce', null)
dialogPage.emit('fnOnce', null)
},
onHide() {
console.log('dialog 1 onHide')
......
......@@ -37,7 +37,7 @@ describe('dialog page', () => {
// 不应触发父页面的生命周期,应该触发:
// 1. openDialogPage success & complete callback
// 2. dialog page 生命周期
expect(lifecycleNum).toBe(13)
expect(lifecycleNum).toBe(7)
await page.callMethod('setLifeCycleNum', 0)
});
......@@ -69,7 +69,7 @@ describe('dialog page', () => {
await page.callMethod('goNextPageOpenDialog1')
await page.waitFor(2000)
if (isWeb) {
await page.waitFor(2000)
await page.waitFor(3000)
}
page = await program.currentPage()
expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
......@@ -235,7 +235,7 @@ describe('dialog page', () => {
});
expect(image2).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(16)
expect(lifecycleNum).toBe(10)
await page.callMethod('closeSpecifiedDialog', 0)
const image3 = await program.screenshot({
......@@ -247,7 +247,7 @@ describe('dialog page', () => {
});
expect(image3).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(13)
expect(lifecycleNum).toBe(7)
await page.callMethod('closeSpecifiedDialog', 1)
const image4 = await program.screenshot({
......@@ -259,7 +259,7 @@ describe('dialog page', () => {
});
expect(image4).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(11)
expect(lifecycleNum).toBe(5)
await page.callMethod('closeSpecifiedDialog', 0)
const image5 = await program.screenshot({
......@@ -271,7 +271,7 @@ describe('dialog page', () => {
});
expect(image5).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(8)
expect(lifecycleNum).toBe(2)
})
......
......@@ -5,11 +5,10 @@
<button class="uni-common-mt" id="open-dialog1-wrong-path" @click="openDialog1WrongPath">open dialog page 1 with
wrong path</button>
<button class="uni-common-mt" id="go-next-page-open-dialog1" @click="goNextPageOpenDialog1">go next page & open
dialog1</button>
<!-- #ifdef APP-ANDROID -->
<button class="uni-common-mt" id="privacy_test" @click="privacy">隐私协议</button>
<!-- #endif -->
dialog1</button>
<!-- #ifdef APP-ANDROID -->
<button class="uni-common-mt" id="privacy_test" @click="privacy">隐私协议</button>
<!-- #endif -->
</view>
</template>
......@@ -44,43 +43,23 @@
})
},
openDialog1() {
const dialogPage = uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
}) !
const fn1 = (options: any | null) => {
console.log('dialogPage1 be triggered fn1', options)
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fn11 = (options: any | null) => {
console.log('dialogPage1 be triggered fn11', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fn2 = (options: any | null) => {
console.log('dialogPage1 be triggered fn2', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fnOnce = (options: any | null) => {
console.log('dialogPage1 be triggered fnOnce', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
dialogPage.on('fn1', fn1)
dialogPage.on('fn1', fn11)
dialogPage.on('fn2', fn2)
dialogPage.once('fnOnce', fnOnce)
})
},
openDialog2() {
uni.openDialogPage({
......@@ -194,12 +173,7 @@
},
getLifeCycleNum(): number {
return state.lifeCycleNum
},
privacy() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-privacytest',
})
},
}
}
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册