diff --git a/pages/API/dialog-page/dialog-1.uvue b/pages/API/dialog-page/dialog-1.uvue
index 12d9d7476ecc1f4aca77c083ac1866c16494007d..328088e309cb06ef3f16fd321a84b32a3e77e05a 100644
--- a/pages/API/dialog-page/dialog-1.uvue
+++ b/pages/API/dialog-page/dialog-1.uvue
@@ -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')
diff --git a/pages/API/dialog-page/dialog-page.test.js b/pages/API/dialog-page/dialog-page.test.js
index a8b4c88c75fc4f04e9a65a7fcb1e3bc521680e7f..f569b65f58f9e0156f00b33240dc8d014bc77425 100644
--- a/pages/API/dialog-page/dialog-page.test.js
+++ b/pages/API/dialog-page/dialog-page.test.js
@@ -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)
})
diff --git a/pages/API/dialog-page/dialog-page.uvue b/pages/API/dialog-page/dialog-page.uvue
index 0933903462daaa0f5ec369581ad8f47228a40d4f..5b9d2b0d40d37fd3e1c7d23f9d00b132f891b9c3 100644
--- a/pages/API/dialog-page/dialog-page.uvue
+++ b/pages/API/dialog-page/dialog-page.uvue
@@ -5,11 +5,10 @@
-
-
-
-
+ dialog1
+
+
+
@@ -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',
- })
- },
+ }
}
}