diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index 137b2c544f67e12bb906a35c5a3a5f09ae0b0700..cc03703c7670f63c2158821a515e9863d617b258 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 8885b93ac15de2c2c99605480776363b65c745fc..0f048f4202bb5937788e147e4b6f5da9719ee2a6 100644 --- a/pages/component/picker-view/picker-view.uvue +++ b/pages/component/picker-view/picker-view.uvue @@ -22,7 +22,8 @@ -