提交 03dcd92d 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

test: 补充 progress/picker-view 事件测试

上级 d9f88214
......@@ -11,6 +11,11 @@ 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', () => {
......@@ -79,4 +84,22 @@ describe('PickerView.uvue', () => {
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)
})
})
......@@ -23,6 +23,7 @@
</template>
<script lang="uts">
import { state, setEventCallbackNum } from '@/store/index.uts'
export default {
data() {
const date = new Date()
......@@ -57,7 +58,24 @@
}
},
methods: {
// 自动化测试
getEventCallbackNum() : number {
return state.eventCallbackNum
},
// 自动化测试
setEventCallbackNum(num : number) {
setEventCallbackNum(num)
},
bindChange(e : UniPickerViewChangeEvent) {
// 自动化测试
console.log(e.target?.tagName,e.type);
if ((e.target?.tagName ?? '').includes('PICKER-VIEW')) {
this.setEventCallbackNum(state.eventCallbackNum + 1)
}
if (e.type === 'change') {
this.setEventCallbackNum(state.eventCallbackNum + 2)
}
const val = e.detail.value
this.result = val
this.year = this.years[val[0]]
......
......@@ -11,6 +11,10 @@ beforeAll(async () => {
await page.waitFor(2000);
})
beforeEach(async () => {
await page.callMethod('setEventCallbackNum', 0)
})
describe('Progress.uvue', () => {
it('percent', async () => {
await page.callMethod('setProgress')
......@@ -80,4 +84,21 @@ describe('Progress.uvue', () => {
})
expect(await el.attribute('background-color')).toEqual('#007aff')
})
it('trigger UniProgressActiveendEvent', async () => {
if (
process.env.uniTestPlatformInfo.startsWith('web')
) {
expect(1).toBe(1)
return
}
await page.setData({
pgList: [21, 40, 60, 80]
})
// 动画执行
await page.waitFor(1000);
const eventCallbackNum = await page.callMethod('getEventCallbackNum')
expect(eventCallbackNum).toBe(3)
})
})
<script>
import { state, setEventCallbackNum } from '@/store/index.uts'
import { ItemType } from '@/components/enum-data/enum-data'
export default {
data() {
......@@ -25,6 +26,15 @@
}
},
methods: {
// 自动化测试
getEventCallbackNum() : number {
return state.eventCallbackNum
},
// 自动化测试
setEventCallbackNum(num : number) {
setEventCallbackNum(num)
},
setProgress() {
this.pgList = [20, 40, 60, 80] as number[]
},
......@@ -32,6 +42,13 @@
this.pgList = [0, 0, 0, 0] as number[]
},
activeend(e : UniProgressActiveendEvent) {
// 自动化测试
if ((e.target?.tagName ?? '').includes('PROGRESS')) {
this.setEventCallbackNum(state.eventCallbackNum + 1)
}
if (e.type === 'activeend') {
this.setEventCallbackNum(state.eventCallbackNum + 2)
}
this.curPercent = e.detail.curPercent
},
progress_touchstart() { console.log("手指触摸动作开始") },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册