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

test(list-view): 补充边界测试

上级 ae26661a
<template>
<list-view>
<slot></slot>
<list-item>start</list-item>
<slot name="default"></slot>
<list-item>middle</list-item>
<slot name="second"></slot>
<list-item>end</list-item>
</list-view>
</template>
describe('list-view-children-in-slot', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
describe('list-view-children-in-slot', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
})
return
}
let page
beforeAll(async () => {
......@@ -12,39 +12,39 @@ describe('list-view-children-in-slot', () => {
})
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}`)
let listItems = await page.$$('list-item')
expect(listItems.length).toBe(9)
let texts = await page.$$('.text-in-list-item')
for (let i = 0; i < texts.length; i++) {
expect(await texts[i].text()).toBe(`${i > (texts.length / 2 - 1)? i - texts.length / 2 : i}`)
}
const addBtn = await page.$('#add-btn')
await addBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(11)
texts = await page.$$('.text-in-list-item')
for (let i = 0; i < texts.length; i++) {
expect(await texts[i].text()).toBe(`${i > (texts.length / 2 - 1)? i - texts.length / 2 : i}`)
}
const emptyBtn = await page.$('#empty-btn')
await emptyBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(3)
await addBtn.tap()
listItems = await page.$$('list-item')
expect(listItems.length).toBe(5)
texts = await page.$$('.text-in-list-item')
for (let i = 0; i < texts.length; i++) {
expect(await texts[i].text()).toBe(`0`)
}
})
})
})
......@@ -6,11 +6,18 @@
<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>
<template #default>
<list-item v-for="item in list" :key="item">
<text class="text-in-list-item">{{item}}</text>
</list-item>
</template>
<template #second>
<list-item v-for="item in list" :key="item">
<text class="text-in-list-item">{{item}}</text>
</list-item>
</template>
</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>
......@@ -29,13 +36,13 @@
list: [0, 1, 2]
}
},
methods: {
addItem(){
this.list.push(this.list.length)
},
emptyList(){
this.list = []
}
methods: {
addItem() {
this.list.push(this.list.length)
},
emptyList() {
this.list = []
}
}
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册