提交 277ddbb6 编写于 作者: H hdx

feat(api): 新增 uni.rpx2px 及自动化测试

上级 e73a8b47
......@@ -679,7 +679,14 @@
"enablePullDownRefresh": false
}
},
// #endif
// #endif
{
"path": "pages/API/rpx2px/rpx2px",
"style": {
"navigationBarTitleText": "rpx2px",
"enablePullDownRefresh": false
}
},
{
"path": "pages/tabBar/CSS",
"style": {
......
const PAGE_PATH = '/pages/API/rpx2px/rpx2px'
describe('API-rpx2px', () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600);
});
it('rpx2px', async () => {
const btnConvert = await page.$('.convert')
await btnConvert.tap()
await page.waitFor(100)
const data = await page.data()
expect(data.result).toBe(true)
});
});
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page">
<page-head :title="title"></page-head>
<view>
<view class="item">
<text class="item-k">输入:</text>
<text class="item-v">{{rpxValue}}rpx</text>
</view>
<view class="item">
<text class="item-k">返回:</text>
<text class="item-v">{{pxValue}}px</text>
</view>
</view>
<view>
<button class="convert" type="primary" @click="rpx2px">转换</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'rpx2px',
rpxValue: 750,
pxValue: 0,
result: false
}
},
methods: {
rpx2px: function () {
this.pxValue = uni.rpx2px(this.rpxValue);
// 仅限自动化测试
const windowInfo = uni.getWindowInfo();
if (windowInfo.windowWidth == this.pxValue) {
this.result = true
}
}
}
}
</script>
<style>
.page {
padding: 15px;
}
.item {
flex-direction: row;
}
.item-k {
width: 72px;
line-height: 2;
}
.item-v {
font-weight: bold;
line-height: 2;
}
</style>
......@@ -186,6 +186,10 @@
name: 'showToast轻提示框',
url: 'toast',
api: ["showToast"]
},
{
name: 'rpx2px',
url: 'rpx2px'
}
] as Page[],
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册