diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index feba2b4d407f5e8144792e2971c3369e5713579c..95c4620d425d4824faf87a773041dcc7cb2aa48e 100644 --- a/pages/component/picker-view/picker-view.test.js +++ b/pages/component/picker-view/picker-view.test.js @@ -1,6 +1,5 @@ - const PAGE_PATH = '/pages/component/picker-view/picker-view' -let page,pickerViewEl; +let page, pickerViewEl; describe('PickerView.uvue', () => { beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) @@ -14,16 +13,22 @@ describe('PickerView.uvue', () => { }) async function toScreenshot(imgName) { - const image = await program.screenshot({fullPage: true}); - expect(image).toSaveImageSnapshot({customSnapshotIdentifier() { - return imgName - }}) + const image = await program.screenshot({ + fullPage: true + }); + expect(image).toSaveImageSnapshot({ + customSnapshotIdentifier() { + return imgName + } + }) await page.waitFor(500); } it('value', async () => { await page.callMethod('setValue') await page.waitFor(1000) + + const newValue1 = await pickerViewEl.property('value') // TODO expect(newValue1.toString()).toEqual('0,0,0') @@ -58,27 +63,31 @@ describe('PickerView.uvue', () => { await toScreenshot('picker-view-indicator-style') }) - if(process.env.uniTestPlatformInfo.startsWith('web')){ + if (process.env.uniTestPlatformInfo.startsWith('web')) { // indicator-class、mask-style、mask-class 仅web支持 it('indicator-class', async () => { await page.setData({ - indicatorStyle:"",//清空indicatorStyle - indicatorClass:"indicator-test",//设置indicatorClass为indicator-test + indicatorStyle: "", //清空indicatorStyle + indicatorClass: "indicator-test", //设置indicatorClass为indicator-test }) expect(await pickerViewEl.attribute('indicatorClass')).toBe("indicator-test") await toScreenshot('picker-view-web-indicator-class') await page.setData({ - indicatorClass:"",//清空indicatorClass + indicatorClass: "", //清空indicatorClass }) }) it('mask-style', async () => { const maskStyle = "background-image: linear-gradient(to bottom, #d8e5ff, rgba(216, 229, 255, 0));" - await page.setData({maskStyle}) + await page.setData({ + maskStyle + }) expect(await pickerViewEl.attribute('maskStyle')).toBe(maskStyle) await toScreenshot('picker-view-web-mask-style') }) it('mask-class', async () => { - await page.setData({maskClass:"mask-test"}) + await page.setData({ + maskClass: "mask-test" + }) expect(await pickerViewEl.attribute('maskClass')).toBe("mask-test") await toScreenshot('picker-view-web-mask-class') }) @@ -121,9 +130,9 @@ describe('PickerView.uvue', () => { await page.callMethod('setValue') await page.waitFor(1500) const eventCallbackNum = await page.callMethod('getEventCallbackNum') - // 3 times 3*3 + // 年月日滚动三次,测试 e.tagName +1 和 e.type+2,正常为9 expect(eventCallbackNum).toBe(9) }) } -}) +}) \ No newline at end of file diff --git a/pages/component/picker-view/picker-view.uvue b/pages/component/picker-view/picker-view.uvue index e2bfac5b59b1ff067d027932b384d75f638d095e..68e746e6b6e36cf51d6e396eb65977cec1797426 100644 --- a/pages/component/picker-view/picker-view.uvue +++ b/pages/component/picker-view/picker-view.uvue @@ -27,13 +27,13 @@ import { state, setEventCallbackNum } from '@/store/index.uts' export default { data() { - const date = new Date() + // 20180112 HBuilderX内测开始 :) const _years : number[] = [] - const _year = date.getFullYear() + const _year = 2018 const _months : number[] = [] - const _month : number = date.getMonth() + 1 + const _month : number = 1 const _days : number[] = [] - const _day = date.getDate() + const _day = 12 for (let i = 2000; i <= _year; i++) { _years.push(i) } @@ -72,8 +72,8 @@ setEventCallbackNum(num) }, bindChange(e : UniPickerViewChangeEvent) { - // 自动化测试 - console.log(e.target?.tagName, e.type); + // 自动化测试 触发事件元素、type 类型 + // console.log(e.target?.tagName, e.type); if ((e.target?.tagName ?? '').includes('PICKER-VIEW')) { this.setEventCallbackNum(state.eventCallbackNum + 1) } @@ -87,7 +87,7 @@ this.day = this.days[val[2]] }, setValue() { - this.value = [0, 0, 0] as number[] + this.value = [0, 1, 30] as number[] }, setValue1() { this.value = [10, 10, 10] as number[] @@ -122,4 +122,4 @@ .mask-test { background-image: linear-gradient(to bottom, #d8e5ff, rgba(216, 229, 255, 0)); } - +