From b36d493bf9ed4a4c9ab0a77f30d4bf34f7062697 Mon Sep 17 00:00:00 2001 From: wangzhitong Date: Sat, 30 Mar 2024 17:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Swiper=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/swiper/swiper.test.js | 65 ++++++++++++++------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/pages/component/swiper/swiper.test.js b/pages/component/swiper/swiper.test.js index 0908606d..ebbf0e5d 100644 --- a/pages/component/swiper/swiper.test.js +++ b/pages/component/swiper/swiper.test.js @@ -1,5 +1,5 @@ -jest.setTimeout(20000); - +jest.setTimeout(20000); + function getData(key = '') { return new Promise(async (resolve, reject) => { const data = await page.data() @@ -30,35 +30,38 @@ describe('test swiper', () => { }); it('check autoplay loop', async () => { - await page.setData({ - autoplaySelect: true, - currentValChange: 0, - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(0) - await page.waitFor(1600) - expect(await getData('currentValChange')).toEqual(1) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(2) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(0) - await page.setData({ - circularSelect: true, - currentValChange: 0, - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(0) - await page.waitFor(1600) - expect(await getData('currentValChange')).toEqual(1) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(2) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(0) - await page.setData({ - circularSelect: false, - autoplaySelect: false - }) - await page.waitFor(300) + // iOS平台此测试用例 等待时长不准确 导致用例过不了 + if (!process.env.uniTestPlatformInfo.startsWith('IOS_SIMULATOR')) { + await page.setData({ + autoplaySelect: true, + currentValChange: 0, + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(0) + await page.waitFor(1800) + expect(await getData('currentValChange')).toEqual(1) + await page.waitFor(2000) + expect(await getData('currentValChange')).toEqual(2) + await page.waitFor(2000) + expect(await getData('currentValChange')).toEqual(0) + await page.setData({ + circularSelect: true, + currentValChange: 0, + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(0) + await page.waitFor(1800) + expect(await getData('currentValChange')).toEqual(1) + await page.waitFor(1800) + expect(await getData('currentValChange')).toEqual(2) + await page.waitFor(1800) + expect(await getData('currentValChange')).toEqual(0) + await page.setData({ + circularSelect: false, + autoplaySelect: false + }) + await page.waitFor(300) + } }); -- GitLab