提交 e868c5f3 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

Merge branch 'dev' of https://gitcode.net/dcloud/hello-uni-app-x into dev

* 'dev' of https://gitcode.net/dcloud/hello-uni-app-x:
  test: 补充 progress/picker-view 事件测试
......@@ -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)
})
})
......@@ -22,7 +22,8 @@
</view>
</template>
<script lang="uts">
<script lang="uts">
import { state, setEventCallbackNum } from '@/store/index.uts'
export default {
data() {
const date = new Date()
......@@ -56,8 +57,25 @@
maskBottomStyle: ''
}
},
methods: {
bindChange(e : UniPickerViewChangeEvent) {
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.
先完成此消息的编辑!
想要评论请 注册