提交 a60cdc8f 编写于 作者: H hdx

test(拦截器):增加switchTab按钮点击,调整自动化测试

上级 d72762e4
...@@ -60,6 +60,7 @@ describe('interceptor', () => { ...@@ -60,6 +60,7 @@ describe('interceptor', () => {
it('addSwitchTabInterceptor', async () => { it('addSwitchTabInterceptor', async () => {
await page.callMethod('addSwitchTabInterceptor') await page.callMethod('addSwitchTabInterceptor')
await page.callMethod('switchTab') await page.callMethod('switchTab')
await page.waitFor(300)
const currentPage = await program.currentPage() const currentPage = await program.currentPage()
expect(currentPage.path).toBe('pages/tabBar/API') expect(currentPage.path).toBe('pages/tabBar/API')
}) })
...@@ -69,6 +70,7 @@ describe('interceptor', () => { ...@@ -69,6 +70,7 @@ describe('interceptor', () => {
await currentPage1.callMethod('addSwitchTabInterceptor') await currentPage1.callMethod('addSwitchTabInterceptor')
await currentPage1.callMethod('removeSwitchTabInterceptor') await currentPage1.callMethod('removeSwitchTabInterceptor')
await currentPage1.callMethod('switchTab') await currentPage1.callMethod('switchTab')
await page.waitFor(300)
const currentPage2 = await program.currentPage() const currentPage2 = await program.currentPage()
expect(currentPage2.path).toBe('pages/tabBar/component') expect(currentPage2.path).toBe('pages/tabBar/component')
}) })
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<navigator url="./page1"> <navigator url="./page1">
<button class="navigatorButton">navigator组件跳转到测试页面</button> <button class="navigatorButton">navigator组件跳转到测试页面</button>
</navigator> </navigator>
<button @click="addSwitchTabInterceptor">添加switchTab拦截器</button>
<button @click="removeSwitchTabInterceptor">移除switchTab拦截器</button>
<button class="navigatorButton" @click="switchTab">switchTab API</button> <button class="navigatorButton" @click="switchTab">switchTab API</button>
</view> </view>
</template> </template>
...@@ -35,7 +37,7 @@ ...@@ -35,7 +37,7 @@
const switchTabInterceptor = { const switchTabInterceptor = {
invoke: function (options : SwitchTabOptions) { invoke: function (options : SwitchTabOptions) {
console.log('拦截 switchTab 接口传入参数为:', options) console.log('拦截 switchTab 接口传入参数为:', options)
options.url = 'pages/tabBar/API' options.url = '/pages/tabBar/API'
}, },
success: function (res : SwitchTabSuccess) { success: function (res : SwitchTabSuccess) {
console.log('拦截 switchTab 接口 success 返回参数为:', res) console.log('拦截 switchTab 接口 success 返回参数为:', res)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册