From 55d552d95309e527ed298e8acaeafa44ec18eb93 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 17 Aug 2023 10:36:32 +0800 Subject: [PATCH] test: navigator --- pages/API/navigator/navigator.test.js | 49 +++- pages/API/navigator/navigator.uvue | 10 - pages/tabBar/API.uvue | 368 +++++++++++++------------- 3 files changed, 232 insertions(+), 195 deletions(-) diff --git a/pages/API/navigator/navigator.test.js b/pages/API/navigator/navigator.test.js index 248c527d..51da0378 100644 --- a/pages/API/navigator/navigator.test.js +++ b/pages/API/navigator/navigator.test.js @@ -1,4 +1,4 @@ -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) + }) }) diff --git a/pages/API/navigator/navigator.uvue b/pages/API/navigator/navigator.uvue index e38bd6f9..6b0774d7 100644 --- a/pages/API/navigator/navigator.uvue +++ b/pages/API/navigator/navigator.uvue @@ -39,9 +39,6 @@ - @@ -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 diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index b95bbf17..47053475 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -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: '退出', -- GitLab