From a47ac0278086abf08df6dcc46aa567b492ebcb17 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 23 Jan 2024 19:52:23 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BC=98=E5=8C=96=20swiper=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/swiper/swiper.test.js | 174 +++++++++++++------------- 1 file changed, 90 insertions(+), 84 deletions(-) diff --git a/pages/component/swiper/swiper.test.js b/pages/component/swiper/swiper.test.js index a68e2482..0908606d 100644 --- a/pages/component/swiper/swiper.test.js +++ b/pages/component/swiper/swiper.test.js @@ -1,86 +1,92 @@ -function getData(key = '') { - return new Promise(async (resolve, reject) => { - const data = await page.data() - resolve(key ? data[key] : data) - }) -} - -let page; -beforeAll(async () => { - page = await program.reLaunch('/pages/component/swiper/swiper') - await page.waitFor(600) -}) - - -describe('test swiper', () => { - - - it('check indicator show', async () => { - await page.setData({ - dotsSelect: true, - }) - await page.waitFor(600) - await page.setData({ - dotsSelect: false, - }) - await page.waitFor(600) - /** - * todo 暂无判断条件 - */ - }); - - 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(2000) - expect(await getData('currentValChange')).toEqual(1) - await page.waitFor(4000) - expect(await getData('currentValChange')).toEqual(0) - await page.setData({ - circularSelect: true, - currentValChange:0, - }) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(1) - await page.waitFor(2000) - expect(await getData('currentValChange')).toEqual(2) - await page.setData({ - circularSelect: false, - autoplaySelect: false - }) - await page.waitFor(300) - }); - - - it('check current', async () => { - await page.setData({ - currentVal: 2, - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(2) - await page.setData({ - currentVal: 0, - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(0) - }); - - it('check currentId', async () => { - await page.setData({ - currentItemIdVal: 'C', - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(2) - await page.setData({ - currentItemIdVal: 'A', - }) - await page.waitFor(600) - expect(await getData('currentValChange')).toEqual(0) - }); +jest.setTimeout(20000); +function getData(key = '') { + return new Promise(async (resolve, reject) => { + const data = await page.data() + resolve(key ? data[key] : data) + }) +} + +let page; +beforeAll(async () => { + page = await program.reLaunch('/pages/component/swiper/swiper') + await page.waitFor(600) +}) + + +describe('test swiper', () => { + it('check indicator show', async () => { + await page.setData({ + dotsSelect: true, + }) + await page.waitFor(600) + await page.setData({ + dotsSelect: false, + }) + await page.waitFor(600) + /** + * todo 暂无判断条件 + */ + }); + + 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) + }); + + + it('check current', async () => { + await page.setData({ + currentVal: 2, + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(2) + await page.setData({ + currentVal: 0, + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(0) + }); + + it('check currentId', async () => { + await page.setData({ + currentItemIdVal: 'C', + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(2) + + await page.setData({ + currentItemIdVal: 'A', + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(0) + }); + }); - -- GitLab