list-view-children-in-slot.test.js 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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}`)
    }
  })
})