list-view-children-in-slot.test.js 1.4 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
describe('list-view-children-in-slot', () => {
2 3 4
  let page
  beforeAll(async () => {
    page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot')
5 6
    await page.waitFor('list-view')
    await page.waitFor(300)
7 8 9
  })

  it('basic', async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
10 11 12 13 14 15 16 17 18 19
    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()
20
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
21 22 23 24 25 26 27 28 29 30 31

    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()
32
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
33 34 35 36
    listItems = await page.$$('list-item')
    expect(listItems.length).toBe(3)

    await addBtn.tap()
37
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
38 39 40 41 42 43
    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`)
44
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
45
  })
46
})