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