From 03dcd92dbeb77ab6fd5afb6f1445fad40f8d074a Mon Sep 17 00:00:00 2001 From: jixinbao Date: Thu, 23 May 2024 17:28:42 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=20progress/picker-vi?= =?UTF-8?q?ew=20=E4=BA=8B=E4=BB=B6=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/picker-view/picker-view.test.js | 69 ++++++++++++------- pages/component/picker-view/picker-view.uvue | 24 ++++++- pages/component/progress/progress.test.js | 21 ++++++ pages/component/progress/progress.uvue | 17 +++++ 4 files changed, 105 insertions(+), 26 deletions(-) diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index 137b2c54..cc03703c 100644 --- a/pages/component/picker-view/picker-view.test.js +++ b/pages/component/picker-view/picker-view.test.js @@ -4,21 +4,26 @@ function getData(key = '') { resolve(key ? data[key] : data) }) } - -const PAGE_PATH = '/pages/component/picker-view/picker-view' + +const PAGE_PATH = '/pages/component/picker-view/picker-view' let page beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor('view') + await page.callMethod('setEventCallbackNum', 0) +}) + +afterEach(async () => { + await page.callMethod('setEventCallbackNum', 0) }) describe('PickerView.uvue', () => { it('value', async () => { const el = await page.$('.picker-view') await page.callMethod('setValue') - await page.waitFor(1000) - const newValue1 = await el.property('value') + await page.waitFor(1000) + const newValue1 = await el.property('value') // TODO expect(newValue1.toString()).toEqual('0,0,0') if (process.env.UNI_PLATFORM === 'app-android') { @@ -26,8 +31,8 @@ describe('PickerView.uvue', () => { } await page.callMethod('setValue1') - await page.waitFor(1000) - const newValue2 = await el.property('value') + await page.waitFor(1000) + const newValue2 = await el.property('value') // TODO expect(newValue2.toString()).toEqual('10,10,10') if (process.env.UNI_PLATFORM === 'app-android') { @@ -62,21 +67,39 @@ describe('PickerView.uvue', () => { maskBottomStyle: 'background: #ffffff;', }) expect(await el.attribute('mask-bottom-style')).toBe('background: #ffffff;') - }) - - it('reopen-picker-view-page', async () => { - page = await program.switchTab('/pages/tabBar/component') - await page.waitFor(500) - page = await program.navigateTo(PAGE_PATH) - await page.waitFor(500) - const date = new Date() - const { - year, - month, - day - } = await page.data() - expect(year).toEqual(date.getFullYear()) - expect(month).toEqual(date.getMonth() + 1) - expect(day).toEqual(date.getDate()) }) -}) + + it('reopen-picker-view-page', async () => { + page = await program.switchTab('/pages/tabBar/component') + await page.waitFor(500) + page = await program.navigateTo(PAGE_PATH) + await page.waitFor(500) + const date = new Date() + const { + year, + month, + day + } = await page.data() + expect(year).toEqual(date.getFullYear()) + expect(month).toEqual(date.getMonth() + 1) + expect(day).toEqual(date.getDate()) + }) + + it('trigger UniPickerViewChangeEvent', async () => { + + // if web skip todo + if ( + process.env.uniTestPlatformInfo.startsWith('web') + ) { + expect(1).toBe(1) + return + } + + const el = await page.$('.picker-view') + await page.callMethod('setValue') + await page.waitFor(1000) + const eventCallbackNum = await page.callMethod('getEventCallbackNum') + // 3 times 3*3 + expect(eventCallbackNum).toBe(9) + }) +}) diff --git a/pages/component/picker-view/picker-view.uvue b/pages/component/picker-view/picker-view.uvue index 8885b93a..0f048f42 100644 --- a/pages/component/picker-view/picker-view.uvue +++ b/pages/component/picker-view/picker-view.uvue @@ -22,7 +22,8 @@ -