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

test: navigator

上级 06825729
jest.setTimeout(40000)
jest.setTimeout(80000)
const CURRENT_PAGE_PATH = '/pages/API/navigator/navigator'
const CHILD1_PAGE_PATH = '/pages/API/navigator/new-page/new-page-1'
const CHILD2_PAGE_PATH = '/pages/API/navigator/new-page/new-page-2'
......@@ -140,6 +140,7 @@ describe('navigator', () => {
})
it('switchTab', async () => {
page = await program.reLaunch(CURRENT_PAGE_PATH)
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('switchTab')
await page.waitFor(500)
......@@ -148,4 +149,50 @@ describe('navigator', () => {
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('20 times navigateTo', async () => {
const originPageStack = await program.pageStack()
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
const newPageStack = await program.pageStack()
expect(newPageStack.length - originPageStack.length).toBe(20)
})
})
......@@ -39,9 +39,6 @@
<button @tap="reLaunch" class="uni-btn">
关闭所有页面,打开首页
</button>
<button @tap="customAnimation" class="uni-btn">
使用自定义动画打开页面
</button>
<button @tap="navigateToErrorPage" class="uni-btn">
打开不存在的页面
</button>
......@@ -346,13 +343,6 @@ export default {
},
})
},
customAnimation() {
uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-1?data=自定义动画打开页面',
animationType: 'slide-in-bottom',
animationDuration: 200,
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
......
......@@ -144,20 +144,20 @@ export default {
open: false,
pages: [
/* {
name: "创建动画",
url: "animation",
enable: false
},
{
name: "创建绘画",
url: "canvas",
enable: false
},
{
name: "节点布局交互状态",
url: "intersection-observer",
enable: false
}, */
name: "创建动画",
url: "animation",
enable: false
},
{
name: "创建绘画",
url: "canvas",
enable: false
},
{
name: "节点布局交互状态",
url: "intersection-observer",
enable: false
}, */
{
name: '节点信息',
url: 'nodes-info',
......@@ -222,57 +222,57 @@ export default {
url: 'get-battery-info',
},
/* {
name: "打电话",
url: "make-phone-call",
},
{
name: "震动",
url: "vibrate",
},
{
name: "添加手机联系人",
url: "add-phone-contact",
},
{
name: "扫码",
url: "scan-code",
},
{
name: "剪贴板",
url: "clipboard",
},
{
name: "屏幕亮度",
url: "brightness",
},
{
name: "蓝牙",
url: "bluetooth",
},
{
name: "生物认证",
url: "soter",
},
{
name: "iBeacon",
url: "ibeacon",
},
{
name: "监听加速度传感器",
url: "on-accelerometer-change",
},
{
name: "监听罗盘数据",
url: "on-compass-change",
},
{
name: "监听距离传感器",
url: "/platforms/app-plus/proximity/proximity",
},
{
name: "监听方向传感器",
url: "/platforms/app-plus/orientation/orientation",
}, */
name: "打电话",
url: "make-phone-call",
},
{
name: "震动",
url: "vibrate",
},
{
name: "添加手机联系人",
url: "add-phone-contact",
},
{
name: "扫码",
url: "scan-code",
},
{
name: "剪贴板",
url: "clipboard",
},
{
name: "屏幕亮度",
url: "brightness",
},
{
name: "蓝牙",
url: "bluetooth",
},
{
name: "生物认证",
url: "soter",
},
{
name: "iBeacon",
url: "ibeacon",
},
{
name: "监听加速度传感器",
url: "on-accelerometer-change",
},
{
name: "监听罗盘数据",
url: "on-compass-change",
},
{
name: "监听距离传感器",
url: "/platforms/app-plus/proximity/proximity",
},
{
name: "监听方向传感器",
url: "/platforms/app-plus/orientation/orientation",
}, */
] as Page[],
},
{
......@@ -319,34 +319,34 @@ export default {
url: 'preview-image',
},
/* {
name: "图片选择和拍照",
url: "image",
enable: false
},{
name: "音频",
url: "inner-audio",
},
{
name: "录音",
url: "voice",
},
{
name: "背景音频",
url: "background-audio",
},
{
name: "视频选择和拍照",
url: "video",
enable: false
},
{
name: "文件",
url: "file",
},
{
name: "保存媒体到本地",
url: "save-media",
}, */
name: "图片选择和拍照",
url: "image",
enable: false
},{
name: "音频",
url: "inner-audio",
},
{
name: "录音",
url: "voice",
},
{
name: "背景音频",
url: "background-audio",
},
{
name: "视频选择和拍照",
url: "video",
enable: false
},
{
name: "文件",
url: "file",
},
{
name: "保存媒体到本地",
url: "save-media",
}, */
] as Page[],
},
{
......@@ -358,22 +358,22 @@ export default {
name: '获取当前位置',
url: 'get-location',
},
/* {
name: "使用地图查看位置",
url: "open-location",
},
{
name: "使用地图选择位置",
url: "choose-location",
},
{
name: "地图控制",
url: "map",
},
{
name: "地图搜索",
url: "map-search",
}, */
/* {
name: "使用地图查看位置",
url: "open-location",
},
{
name: "使用地图选择位置",
url: "choose-location",
},
{
name: "地图控制",
url: "map",
},
{
name: "地图搜索",
url: "map-search",
}, */
] as Page[],
},
{
......@@ -387,81 +387,81 @@ export default {
},
] as Page[],
},
/* {
id: "rewarded-video-ad",
url: "rewarded-video-ad",
name: "激励视频广告",
open: false,
enable: false,
pages: [] as Page[]
},
{
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
open: false,
enable: false,
pages: [] as Page[]
},
{
id: "login",
name: "登录",
open: false,
pages: [
{
name: "登录",
url: "login",
},
{
name: "获取用户信息",
url: "get-user-info",
},
] as Page[],
},
{
id: "share",
name: "分享",
open: false,
pages: [
{
name: "分享",
url: "share",
},
] as Page[],
},
{
id: "payment",
name: "支付",
open: false,
pages: [
{
name: "发起支付",
url: "request-payment",
},
] as Page[],
},
{
id: "speech",
name: "语音",
open: false,
pages: [
{
name: "语音识别",
url: "/platforms/app-plus/speech/speech",
},
] as Page[],
},
{
id: "push",
name: "推送",
open: false,
pages: [
{
name: "推送",
url: "/platforms/app-plus/push/push",
},
] as Page[],
}, */
/* {
id: "rewarded-video-ad",
url: "rewarded-video-ad",
name: "激励视频广告",
open: false,
enable: false,
pages: [] as Page[]
},
{
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
open: false,
enable: false,
pages: [] as Page[]
},
{
id: "login",
name: "登录",
open: false,
pages: [
{
name: "登录",
url: "login",
},
{
name: "获取用户信息",
url: "get-user-info",
},
] as Page[],
},
{
id: "share",
name: "分享",
open: false,
pages: [
{
name: "分享",
url: "share",
},
] as Page[],
},
{
id: "payment",
name: "支付",
open: false,
pages: [
{
name: "发起支付",
url: "request-payment",
},
] as Page[],
},
{
id: "speech",
name: "语音",
open: false,
pages: [
{
name: "语音识别",
url: "/platforms/app-plus/speech/speech",
},
] as Page[],
},
{
id: "push",
name: "推送",
open: false,
pages: [
{
name: "推送",
url: "/platforms/app-plus/push/push",
},
] as Page[],
}, */
{
id: 'exit',
name: '退出',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册