list-view-children-in-slot.test.js 1.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')

DCloud-WZF's avatar
DCloud-WZF 已提交
4
describe('list-view-children-in-slot', () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
5 6 7 8 9 10 11
  if (isMP) {
  	it('skip mp', () => {
  		expect(1).toBe(1)
  	})
  	return
  }

12 13 14 15
  let page
  beforeAll(async () => {
    page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot')
    await page.waitFor('list-view')
16
    await page.waitFor(300)
17 18 19
  })

  it('basic', async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
20 21 22 23 24 25 26 27 28 29
    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()
30
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
31 32 33 34 35 36 37 38 39 40 41

    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()
42
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
43 44 45 46
    listItems = await page.$$('list-item')
    expect(listItems.length).toBe(3)

    await addBtn.tap()
47
    await page.waitFor(500)
DCloud-WZF's avatar
DCloud-WZF 已提交
48 49 50 51 52 53
    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`)
54
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
55
  })
56
})