提交 fe2bcdb6 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test(component): general attribute and event

上级 8a7871ec
......@@ -14,6 +14,7 @@ describe('general attribute', () => {
it('validateGeneralAttributes', async () => {
const button = await page.$('.btn')
await button.tap()
expect(await button.text()).toBe('基础属性验证成功')
const btnInner = await page.$('.btn-inner')
expect(await btnInner.text()).toBe('基础属性验证成功')
})
})
......@@ -6,7 +6,9 @@
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt container">
<view :id="generalId" :class="generalClass" :name="generalName" :title="generalTitle" :data-test="generalData" style="background-color: aqua" ref="general-target"> </view>
<button class="btn uni-common-mt" @click="validateGeneralAttributes">{{ validateGeneralAttrText }}</button>
<view class="btn uni-common-mt" @click="validateGeneralAttributes">
<text class="btn-inner">{{ validateGeneralAttrText }}</text>
</view>
<view class="view-class" :hover-class="hoverClass" ref="view-target">
<text class="text">按下 50 ms 后背景变红</text>
<text class="text">抬起 400 ms 后背景恢复</text>
......@@ -72,6 +74,17 @@ export default {
</script>
<style>
.btn {
height: 50px;
display: flex;
align-items: center;
justify-content: center;
background-color: #409eff;
border-radius: 5px;
}
.btn-inner {
color: #fff;
}
.general-class {
margin: 20px 0 0 50px;
width: 240px;
......@@ -86,7 +99,7 @@ export default {
background-color: antiquewhite;
}
.view-class .text {
margin-top: 5px;
margin-top: 5px;
text-align: center;
}
.hover-class {
......
......@@ -60,13 +60,12 @@ describe('event trigger sequence', () => {
it('click', async () => {
await el.tap()
const data = await page.data()
expect(data.onTapTime).toBeLessThan(data.onClickTime)
expect(data.onTapTime).toBeLessThanOrEqual(data.onClickTime)
})
it('longPress', async () => {
const now = Date.now()
await el.longpress()
const data = await page.data()
expect(now).toBeLessThan(data.onLongPressTime)
expect(data.onLongPressTime).toBeGreaterThan(0)
})
})
......@@ -93,31 +93,31 @@ export default {
onTouchStart(e: TouchEvent){
this.touchStartEvent = e
this.onTouchStartTime = Date.now()
console.warn('onTouchStart', this.onTouchStartTime)
console.log('onTouchStart')
},
onTouchMove(e: TouchEvent){
this.touchMoveEvent = e
this.onTouchMoveTime = Date.now()
console.warn('onTouchMove', this.onTouchMoveTime)
console.log('onTouchMove')
},
onTouchEnd(e: TouchEvent){
this.touchEndEvent = e
this.onTouchEndTime = Date.now()
console.warn('onTouchEnd', this.onTouchEndTime)
console.log('onTouchEnd')
},
onTap(e: MouseEvent){
this.tapEvent = e
this.onTapTime = Date.now()
console.warn('onTap', this.onTapTime)
console.log('onTap')
},
onClick(e: MouseEvent){
this.clickEvent = e
this.onClickTime = Date.now()
console.warn('onClick', this.onClickTime)
console.log('onClick')
},
onLongPress(){
this.onLongPressTime = Date.now()
console.warn('onLongPress', this.onLongPressTime)
console.log('onLongPress')
},
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册