提交 2a6760be 编写于 作者: Anne_LXM's avatar Anne_LXM

test(scroll-view.test.js/list-view.test.js): issues2420修复更新测试例

上级 190dae61
...@@ -38,10 +38,8 @@ describe('component-native-list-view', () => { ...@@ -38,10 +38,8 @@ describe('component-native-list-view', () => {
await page.waitFor(600) await page.waitFor(600)
await page.callMethod('confirm_scroll_top_input', 300) await page.callMethod('confirm_scroll_top_input', 300)
await page.waitFor(600) await page.waitFor(600)
// 在web端scroll事件event参数中detail类型报错,先忽略测试
if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){
const scrollDetail = await page.data('scrollDetailTest') const scrollDetail = await page.data('scrollDetailTest')
console.log('scrollDetailTest:', scrollDetail) // console.log('scrollDetailTest:', scrollDetail)
expect(scrollDetail.scrollLeft).toBe(0) expect(scrollDetail.scrollLeft).toBe(0)
// scrollTop和deltaY 在安卓端差异 299.8095 // scrollTop和deltaY 在安卓端差异 299.8095
expect([300, 299.8095]).toContain(scrollDetail.scrollTop); expect([300, 299.8095]).toContain(scrollDetail.scrollTop);
...@@ -49,7 +47,6 @@ describe('component-native-list-view', () => { ...@@ -49,7 +47,6 @@ describe('component-native-list-view', () => {
expect(scrollDetail.scrollWidth).toBeGreaterThan(0) expect(scrollDetail.scrollWidth).toBeGreaterThan(0)
expect(scrollDetail.deltaX).toBe(0) expect(scrollDetail.deltaX).toBe(0)
expect([300, 299.8095]).toContain(scrollDetail.deltaY); expect([300, 299.8095]).toContain(scrollDetail.deltaY);
}
expect(await page.data('isScrollTest')).toBe('scroll:Success') expect(await page.data('isScrollTest')).toBe('scroll:Success')
}) })
...@@ -84,7 +81,7 @@ describe('component-native-list-view', () => { ...@@ -84,7 +81,7 @@ describe('component-native-list-view', () => {
}) })
await page.waitFor(600) await page.waitFor(600)
const endDetail = await page.data('scrollEndDetailTest') const endDetail = await page.data('scrollEndDetailTest')
console.log('scrollEndDetailTest:', endDetail) // console.log('scrollEndDetailTest:', endDetail)
expect(endDetail.deltaY).toBe(0) expect(endDetail.deltaY).toBe(0)
expect(endDetail.deltaX).toBe(0) expect(endDetail.deltaX).toBe(0)
expect(endDetail.scrollLeft).toBe(0) expect(endDetail.scrollLeft).toBe(0)
......
...@@ -34,11 +34,8 @@ ...@@ -34,11 +34,8 @@
isScrollTest:'', isScrollTest:'',
isScrolltolowerTest:'', isScrolltolowerTest:'',
isScrolltoupperTest:'', isScrolltoupperTest:'',
// 在web端scroll事件event参数中detail类型报错,先条件编译处理
// #ifndef WEB
scrollDetailTest:null as UniScrollEventDetail|null, scrollDetailTest:null as UniScrollEventDetail|null,
scrollEndDetailTest:null as UniScrollEventDetail|null, scrollEndDetailTest:null as UniScrollEventDetail|null,
// #endif
} }
}, },
onLoad() { onLoad() {
...@@ -103,9 +100,7 @@ ...@@ -103,9 +100,7 @@
}, },
list_view_scroll(e:UniScrollEvent) { list_view_scroll(e:UniScrollEvent) {
console.log("滚动时触发,event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}") console.log("滚动时触发,event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}")
// #ifndef WEB
this.scrollDetailTest = e.detail this.scrollDetailTest = e.detail
// #endif
this.checkEventTest({ this.checkEventTest({
type:e.type, type:e.type,
target:e.target, target:e.target,
...@@ -114,9 +109,7 @@ ...@@ -114,9 +109,7 @@
}, },
list_view_scrollend(e:UniScrollEvent){ list_view_scrollend(e:UniScrollEvent){
console.log("滚动结束时触发",e.detail) console.log("滚动结束时触发",e.detail)
// #ifndef WEB
this.scrollEndDetailTest = e.detail this.scrollEndDetailTest = e.detail
// #endif
this.checkEventTest({ this.checkEventTest({
type:e.type, type:e.type,
target:e.target, target:e.target,
......
...@@ -20,11 +20,9 @@ describe('component-native-scroll-view', () => { ...@@ -20,11 +20,9 @@ describe('component-native-scroll-view', () => {
// 纵向滚动 // 纵向滚动
await page.setData({scrollTop: 100}) await page.setData({scrollTop: 100})
await page.waitFor(1000) await page.waitFor(1000)
// bug:在web端scroll事件event参数中detail类型报错
if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){
// 设置top 是否触发scroll 事件 // 设置top 是否触发scroll 事件
const topScrollDetail = await page.data('scrollDetailTest') const topScrollDetail = await page.data('scrollDetailTest')
console.log('topScrollDetail:', topScrollDetail) // console.log('topScrollDetail:', topScrollDetail)
expect(topScrollDetail.scrollLeft).toBe(0) expect(topScrollDetail.scrollLeft).toBe(0)
// Android 差异scrollTop:99.809525 // Android 差异scrollTop:99.809525
expect([100, 99.809525]).toContain(topScrollDetail.scrollTop); expect([100, 99.809525]).toContain(topScrollDetail.scrollTop);
...@@ -32,7 +30,6 @@ describe('component-native-scroll-view', () => { ...@@ -32,7 +30,6 @@ describe('component-native-scroll-view', () => {
expect(topScrollDetail.scrollWidth).toBeGreaterThan(0) expect(topScrollDetail.scrollWidth).toBeGreaterThan(0)
expect(topScrollDetail.deltaX).toBe(0) expect(topScrollDetail.deltaX).toBe(0)
expect(topScrollDetail.deltaY).not.toBe(0) expect(topScrollDetail.deltaY).not.toBe(0)
}
expect(await page.data('isScrollTest')).toBe('scroll:Success') expect(await page.data('isScrollTest')).toBe('scroll:Success')
}) })
...@@ -40,10 +37,9 @@ describe('component-native-scroll-view', () => { ...@@ -40,10 +37,9 @@ describe('component-native-scroll-view', () => {
// 横向滚动 // 横向滚动
await page.setData({scrollLeft:220}) await page.setData({scrollLeft:220})
await page.waitFor(600) await page.waitFor(600)
if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){
//设置left 是否触发scroll 事件 //设置left 是否触发scroll 事件
const leftScrollDetail = await page.data('scrollDetailTest') const leftScrollDetail = await page.data('scrollDetailTest')
console.log('leftScrollDetail:', leftScrollDetail) // console.log('leftScrollDetail:', leftScrollDetail)
// Android 差异scrollLeft:219.80952 // Android 差异scrollLeft:219.80952
expect([220, 219.80952]).toContain(leftScrollDetail.scrollLeft); expect([220, 219.80952]).toContain(leftScrollDetail.scrollLeft);
expect(leftScrollDetail.scrollTop).toBe(0) expect(leftScrollDetail.scrollTop).toBe(0)
...@@ -52,7 +48,6 @@ describe('component-native-scroll-view', () => { ...@@ -52,7 +48,6 @@ describe('component-native-scroll-view', () => {
// 在安卓差异 -99.809525 // 在安卓差异 -99.809525
expect([-100, -99.809525]).toContain(leftScrollDetail.deltaX); expect([-100, -99.809525]).toContain(leftScrollDetail.deltaX);
expect(leftScrollDetail.deltaY).toBe(0) expect(leftScrollDetail.deltaY).toBe(0)
}
expect(await page.data('isScrollTest')).toBe('scroll:Success') expect(await page.data('isScrollTest')).toBe('scroll:Success')
}) })
...@@ -74,7 +69,7 @@ describe('component-native-scroll-view', () => { ...@@ -74,7 +69,7 @@ describe('component-native-scroll-view', () => {
if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){ if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){
it('Event scrollend-滚动结束时触发仅App端支持',async()=>{ it('Event scrollend-滚动结束时触发仅App端支持',async()=>{
const endDetail = await page.data('scrollEndDetailTest') const endDetail = await page.data('scrollEndDetailTest')
console.log('scrollEndDetailTest:', endDetail) // console.log('scrollEndDetailTest:', endDetail)
expect(endDetail.scrollLeft).toBe(0) expect(endDetail.scrollLeft).toBe(0)
expect(endDetail.scrollTop).toBe(0) expect(endDetail.scrollTop).toBe(0)
expect(endDetail.deltaY).toBe(0) expect(endDetail.deltaY).toBe(0)
......
...@@ -80,11 +80,8 @@ ...@@ -80,11 +80,8 @@
isScrollTest:'', isScrollTest:'',
isScrolltolowerTest:'', isScrolltolowerTest:'',
isScrolltoupperTest:'', isScrolltoupperTest:'',
// 在web端scroll事件event参数中detail类型报错,先条件编译处理
// #ifndef WEB
scrollDetailTest:null as UniScrollEventDetail|null, scrollDetailTest:null as UniScrollEventDetail|null,
scrollEndDetailTest:null as UniScrollEventDetail|null, scrollEndDetailTest:null as UniScrollEventDetail|null,
// #endif
} }
}, },
methods: { methods: {
...@@ -107,9 +104,7 @@ ...@@ -107,9 +104,7 @@
} as ScrollEventTest,'scrolltolower') } as ScrollEventTest,'scrolltolower')
}, },
scroll: function (e : UniScrollEvent) { scroll: function (e : UniScrollEvent) {
// #ifndef WEB
this.scrollDetailTest = e.detail this.scrollDetailTest = e.detail
// #endif
this.checkEventTest({ this.checkEventTest({
type:e.type, type:e.type,
target:e.target, target:e.target,
...@@ -119,9 +114,7 @@ ...@@ -119,9 +114,7 @@
}, },
end: function (e : UniScrollEvent){ end: function (e : UniScrollEvent){
console.log('滚动结束时触发',e) console.log('滚动结束时触发',e)
// #ifndef WEB
this.scrollEndDetailTest = e.detail this.scrollEndDetailTest = e.detail
// #endif
this.checkEventTest({ this.checkEventTest({
type:e.type, type:e.type,
target:e.target, target:e.target,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册