提交 e80ea7b6 编写于 作者: Anne_LXM's avatar Anne_LXM

新增page-meta示例

上级 828f8a2d
jest.setTimeout(30000);
describe('test page-meta', () => {
let page,titleEl,cellEl;
if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
it('not support', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch('/pages/component/page-meta/page-meta')
await page.waitFor(3000);
titleEl = await page.$(".title")
cellEl = await page.$(".uni-list-cell")
});
it('check page-style', async () => {
expect(await titleEl.style('color')).toEqual('rgb(0, 128, 0)');
expect(await cellEl.style('color')).toEqual('rgb(0, 128, 0)');
});
it('check root-font-size', async () => {
expect(await titleEl.style('font-size')).toEqual('30px');
});
it('check scrollTop', async () => {
expect(await page.data('scrollTop')).toEqual('0px');
const buttonEl = await page.$("button")
await buttonEl.tap()
await page.waitFor(2100)
console.log('scrollType',await page.data('scrollType'));
expect(await page.data('scrollTop')).toEqual('300px');
expect(await page.data('scrollType')).toEqual('scroll');
expect(await page.data('scrolldoneType')).toEqual('scrolldone');
});
});
<template>
<page-meta
:background-text-style="bgTextStyle"
:background-color="bgColor"
:background-color-top="bgColorTop"
:background-color-bottom="bgColorBottom"
:scroll-top="scrollTop"
:scroll-duration="2000"
@scroll="scroll"
@scrolldone="scrolldone"
page-style="color: green"
root-font-size="30px"
>
<navigation-bar
:title="nbTitle"
:loading="nbLoading"
:front-color="nbFrontColor"
:background-color="nbBackgroundColor"
/>
</page-meta>
<view class="content">
<text class="title">页面内容</text>
<button @click="scrollTo">点击跳到 300px 处</button>
<view class="uni-list" v-for="(_, index) in 30" :key="index">
<view class="uni-list-cell">{{ index }}</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
bgTextStyle: 'dark',
scrollTop: '0px',
bgColor: '#ff0000',
bgColorTop: '#00ff00',
bgColorBottom: '#0000ff',
nbTitle: '标题',
nbLoading: false,
nbFrontColor: '#ffffff',
nbBackgroundColor: '#00aaff',
// 自动化测试
scrollType:null,
scrolldoneType:null,
}
},
onLoad() {
setTimeout(()=>{
this.nbLoading = true
},2000)
},
methods: {
scrollTo(){
this.scrollTop = '300px'
},
scroll(e){
this.scrollType=e.type
},
scrolldone(e){
this.scrolldoneType=e.type
}
}
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册