diff --git a/pages/API/rpx2px/rpx2px.test.js b/pages/API/rpx2px/rpx2px.test.js new file mode 100644 index 0000000000000000000000000000000000000000..acfb7c0a05b1ccb2216ec83d8f3728d85e122b31 --- /dev/null +++ b/pages/API/rpx2px/rpx2px.test.js @@ -0,0 +1,16 @@ +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) + }); +}); diff --git a/pages/API/rpx2px/rpx2px.uvue b/pages/API/rpx2px/rpx2px.uvue index c07322cc4e7ef7be580aa2a5340114b79a5a53af..1b0d5d889d5a8cdd15ea21aa751bfca660e80875 100644 --- a/pages/API/rpx2px/rpx2px.uvue +++ b/pages/API/rpx2px/rpx2px.uvue @@ -15,7 +15,7 @@ - + @@ -35,6 +35,12 @@ methods: { rpx2px: function () { this.pxValue = uni.rpx2px(this.rpxValue); + + // 仅限自动化测试 + const windowInfo = uni.getWindowInfo(); + if (windowInfo.windowWidth == this.pxValue) { + this.result = true + } } } }