提交 b9a4a670 编写于 作者: 雪洛's avatar 雪洛

test: 增加动态修改下拉刷新并触发下拉刷新的测试例

上级 46988b0e
...@@ -365,6 +365,13 @@ ...@@ -365,6 +365,13 @@
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{
"path": "pages/API/get-current-pages/set-page-style-disable-pull-down-refresh",
"style": {
"navigationBarTitleText": "setPageStyle pull default false",
"enablePullDownRefresh": false
}
},
{ {
"path": "pages/API/get-launch-options-sync/get-launch-options-sync", "path": "pages/API/get-launch-options-sync/get-launch-options-sync",
"style": { "style": {
......
...@@ -40,5 +40,18 @@ describe('getCurrentPages', () => { ...@@ -40,5 +40,18 @@ describe('getCurrentPages', () => {
await page.waitFor(200) await page.waitFor(200)
const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh2).toBe(false) expect(isEnablePullDownRefresh2).toBe(false)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({fullPage: true});
expect(image2).toSaveImageSnapshot();
await page.waitFor(3500)
await page.callMethod('setPageStyle', true)
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({fullPage: true});
expect(image3).toSaveImageSnapshot();
}) })
}) })
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
}); });
this.enablePullDownRefreshStatus = enable this.enablePullDownRefreshStatus = enable
}, },
startPullDownRefresh() {
uni.startPullDownRefresh()
}
// getCurrentPage(): Page { // getCurrentPage(): Page {
// const pages = getCurrentPages(); // const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1]; // const currentPage = pages[pages.length - 1];
......
const PAGE_PATH = '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
describe('getCurrentPages', () => {
let page
it('page-style', async () => {
page = await program.navigateTo(PAGE_PATH)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh1 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh1).toBe(false)
await page.callMethod('setPageStyle', true)
await page.waitFor(200)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh2).toBe(true)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({fullPage: true});
expect(image3).toSaveImageSnapshot();
await page.waitFor(3500)
// setPageStyle
await page.callMethod('setPageStyle', false)
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({fullPage: true});
expect(image2).toSaveImageSnapshot();
})
})
<template>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<text class="page-style">当前 PageStyle</text>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text>
<view class="status-list">
<text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text>
</view>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
</view>
</template>
<script>
class Page {
constructor(public route : string) {
}
}
export default {
data() {
return {
checked: false,
pages: [] as Page[],
currentPageStyle: {} as UTSJSONObject,
// TODO
enablePullDownRefreshStatus: true
}
},
computed: {
pageStyleText() : string {
return JSON.stringify(this.currentPageStyle)
}
},
onPullDownRefresh() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
},
methods: {
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
},
startPullDownRefresh() {
uni.startPullDownRefresh()
}
},
}
</script>
<style>
.btn {
margin-top: 10px;
}
.page-style {
margin-top: 15px;
}
.page-style-value {
margin-top: 5px;
padding: 5px;
background-color: #fff;
width: 100%;
}
.status {
margin-top: 20px;
}
.status-list {
margin-top: 5px;
}
.tips {
font-size: 12px;
margin-top: 15px;
opacity: .8;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册