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

feat(list-view): 补充测试例 #388

上级 66a710fb
...@@ -69,6 +69,12 @@ ...@@ -69,6 +69,12 @@
"navigationBarTitleText": "list-view-multiplex-video" "navigationBarTitleText": "list-view-multiplex-video"
} }
}, },
{
"path": "pages/component/list-view/list-view-children-in-slot",
"style": {
"navigationBarTitleText": "list-view-children-in-slot"
}
},
{ {
"path": "pages/component/sticky-section/sticky-section", "path": "pages/component/sticky-section/sticky-section",
"style": { "style": {
......
<template>
<list-view>
<slot></slot>
</list-view>
</template>
describe('list-view-children-in-slot', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot')
await page.waitFor('list-view')
})
it('basic', async () => {
let listItems = await page.$$('list-item')
expect(listItems.length).toBe(3)
let texts = await page.$$('.text-in-list-item')
for(let i = 0;i<texts.length;i++){
expect(await texts[i].text()).toBe(`${i}`)
}
const addBtn = await page.$('#add-btn')
await addBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(4)
texts = await page.$$('.text-in-list-item')
for(let i = 0;i<texts.length;i++){
expect(await texts[i].text()).toBe(`${i}`)
}
const emptyBtn = await page.$('#empty-btn')
await emptyBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(0)
await addBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(1)
texts = await page.$$('.text-in-list-item')
for(let i = 0;i<texts.length;i++){
expect(await texts[i].text()).toBe(`${i}`)
}
})
})
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1;padding-bottom: 20px;">
<!-- #endif -->
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<list-view-wrapper>
<list-item v-for="item in list" :key="item">
<text class="text-in-list-item">{{item}}</text>
</list-item>
</list-view-wrapper>
<button id="add-btn" class="uni-common-mt" @click="addItem">add item</button>
<button id="empty-btn" class="uni-common-mt" @click="emptyList">empty list</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import ListViewWrapper from './ListViewWrapper.uvue'
export default {
components: { ListViewWrapper },
data() {
return {
list: [0, 1, 2]
}
},
methods: {
addItem(){
this.list.push(this.list.length)
},
emptyList(){
this.list = []
}
}
}
</script>
...@@ -198,6 +198,11 @@ ...@@ -198,6 +198,11 @@
list-view 复用测试(item中嵌入video) list-view 复用测试(item中嵌入video)
</button> </button>
</navigator> </navigator>
<navigator url="/pages/component/list-view/list-view-children-in-slot" hover-class="none">
<button type="primary" class="button">
list-view 测试插槽中子组件增删
</button>
</navigator>
</view> </view>
</scroll-view> </scroll-view>
</template> </template>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册