提交 7f361455 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

fix(picker-view): 初始化展示日期为静态值,避免每次截图不同、日期相同导致不滚动

上级 d51aec04
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
......@@ -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));
}
</style>
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册