Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
088fc47d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
088fc47d
编写于
9月 28, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(lifecycle): onLoad 生命周期调用路由及弹框 API
上级
0226f567
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
222 addition
and
2 deletion
+222
-2
pages.json
pages.json
+8
-2
pages/API/navigator/new-page/new-page-1.uvue
pages/API/navigator/new-page/new-page-1.uvue
+5
-0
pages/API/navigator/new-page/onLoad.test.js
pages/API/navigator/new-page/onLoad.test.js
+98
-0
pages/API/navigator/new-page/onLoad.uvue
pages/API/navigator/new-page/onLoad.uvue
+111
-0
未找到文件。
pages.json
浏览文件 @
088fc47d
...
@@ -263,6 +263,12 @@
...
@@ -263,6 +263,12 @@
"enablePullDownRefresh"
:
true
"enablePullDownRefresh"
:
true
}
}
},
},
{
"path"
:
"pages/API/navigator/new-page/onLoad"
,
"style"
:
{
"navigationBarTitleText"
:
"onLoad 生命周期测试"
}
},
{
{
"path"
:
"pages/API/pull-down-refresh/pull-down-refresh"
,
"path"
:
"pages/API/pull-down-refresh/pull-down-refresh"
,
"style"
:
{
"style"
:
{
...
@@ -939,13 +945,13 @@
...
@@ -939,13 +945,13 @@
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义TabBar"
"navigationBarTitleText"
:
"自定义TabBar"
}
}
},
{
},
{
"path"
:
"pages/API/facial-recognition-verify/facial-recognition-verify"
,
"path"
:
"pages/API/facial-recognition-verify/facial-recognition-verify"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
""
,
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
"enablePullDownRefresh"
:
false
}
}
}
}
],
],
"globalStyle"
:
{
"globalStyle"
:
{
...
...
pages/API/navigator/new-page/new-page-1.uvue
浏览文件 @
088fc47d
...
@@ -39,6 +39,11 @@ export default {
...
@@ -39,6 +39,11 @@ export default {
},
},
})
})
},
},
navigateToOnLoadWithType(type: string) {
uni.navigateTo({
url: `/pages/API/navigator/new-page/onLoad?type=${type}`,
})
}
},
},
}
}
</script>
</script>
pages/API/navigator/new-page/onLoad.test.js
0 → 100644
浏览文件 @
088fc47d
jest
.
setTimeout
(
20000
);
const
PAGE_PATH
=
"
/pages/API/navigator/new-page/onLoad
"
;
const
INTERMEDIATE_PAGE_PATH
=
"
/pages/API/navigator/new-page/new-page-1
"
;
const
TARGET_PAGE_PATH
=
"
/pages/API/navigator/new-page/new-page-2
"
;
let
page
;
describe
(
"
onLoad
"
,
()
=>
{
it
(
"
adjustData
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
adjustData
"
);
await
page
.
waitFor
(
1000
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
// 先出现 TARGET_PAGE_PATH 页面,再出现 onLoad 页面, 顺序异常
// it("navigateTo", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "navigateTo");
// await page.waitFor(1000);
// page = await program.currentPage();
// expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
// });
// 页面白屏
// it("navigateBack", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "navigateBack");
// await page.waitFor(1000);
// page = await program.currentPage();
// expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
// });
// 直接出现 TARGET_PAGE_PATH 页面,又动画了 TARGET_PAGE_PATH 页面
// it("redirectTo", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "redirectTo");
// await page.waitFor(1000);
// page = await program.currentPage();
// expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
// });
// 直接出现 TARGET_PAGE_PATH 页面,又动画了 TARGET_PAGE_PATH 页面
// it("reLaunch", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "reLaunch");
// await page.waitFor(1000);
// page = await program.currentPage();
// expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
// });
// 页面白屏
// it("switchTab", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "switchTab");
// await page.waitFor(1000);
// page = await program.currentPage();
// expect(page.path).toBe("pages/tabBar/component");
// });
// toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面)
// 当 navigateTo 到 onLoad 页面时,toast 会被关闭
// it("showToast", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "showToast");
// await page.waitFor(1000);
// const image = await program.screenshot();
// expect(image).toMatchImageSnapshot();
// });
// 同 toast
// it("showLoading", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "showLoading");
// await page.waitFor(1000);
// const image = await program.screenshot();
// expect(image).toMatchImageSnapshot();
// });
// 同 toast
// it("showModal", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "showModal");
// await page.waitFor(1000);
// const image = await program.screenshot();
// expect(image).toMatchImageSnapshot();
// });
// 同 toast
// it("showActionSheet", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500);
// await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
// await page.waitFor(1000);
// const image = await program.screenshot();
// expect(image).toMatchImageSnapshot();
// });
});
pages/API/navigator/new-page/onLoad.uvue
0 → 100644
浏览文件 @
088fc47d
<template>
<view class="uni-padding-wrap">
<page-head title="onLoad 生命周期调用 uni api 测试" />
<text v-if="isTrue">v-if with true</text>
<text v-if="isFalse">v-if with false</text>
<text v-show="isTrue">v-show with true</text>
<text v-show="isFalse">v-show with false</text>
<text>msg: {{ msg }}</text>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
isTrue: false,
isFalse: true,
msg: 'default msg'
}
},
onLoad(options: OnLoadOptions) {
const type = options.get('type')
switch (type) {
case 'adjustData':
this.adjustData()
break;
case 'navigateTo':
this.navigateTo()
break;
case 'navigateBack':
this.navigateBack()
break;
case 'redirectTo':
this.redirectTo()
break;
case 'reLaunch':
this.reLaunch()
break;
case 'switchTab':
this.switchTab()
break;
case 'showToast':
this.showToast()
break;
case 'showLoading':
this.showLoading()
break;
case 'showModal':
this.showModal()
break;
case 'showActionSheet':
this.showActionSheet()
break;
}
},
methods: {
adjustData(){
this.isTrue = true
this.isFalse = false
this.msg = 'new msg'
},
navigateTo(){
uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-2'
})
},
navigateBack(){
uni.navigateBack()
},
redirectTo(){
uni.redirectTo({
url: '/pages/API/navigator/new-page/new-page-2'
})
},
reLaunch(){
uni.reLaunch({
url: '/pages/API/navigator/new-page/new-page-2'
})
},
switchTab(){
uni.switchTab({
url: '/pages/tabBar/component'
})
},
showToast(){
uni.showToast({
title: 'test title',
icon: 'success',
duration: 2000
})
},
showLoading(){
uni.showLoading({
title: 'test title',
})
},
showModal(){
uni.showModal({
title: 'test title',
content: 'test content',
})
},
showActionSheet(){
uni.showActionSheet({
title: 'test title',
itemList: ['1', '2', '3']
})
}
}
}
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录