text-props.test.js 1.7 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const PAGE_PATH = '/pages/component/text/text-props'

describe('text-props', () => {
4
  let page
DCloud-WZF's avatar
DCloud-WZF 已提交
5
  beforeAll(async () => {
6
    page = await program.navigateTo(PAGE_PATH)
DCloud-WZF's avatar
DCloud-WZF 已提交
7 8
    await page.waitFor(1000)
  })
9

DCloud-WZF's avatar
DCloud-WZF 已提交
10 11
  it('screenshot', async () => {
    const image = await program.screenshot({ fullPage: true })
12
    expect(image).toSaveImageSnapshot()
DCloud-WZF's avatar
DCloud-WZF 已提交
13
  })
14 15

  it('empty text', async () => {
16 17 18
      await page.setData({
        autoTest: true
      })
19 20 21 22 23 24
      const element = await page.$('#empty-text')
      if (element != null) {
        const { width, height } = await element.size()
        expect(width).toBe(0)
        expect(height).toBe(0)
      }
25
      await page.callMethod("setEmptyText")
26
      await page.waitFor(100)
27 28 29 30 31 32 33 34 35
      const element2 = await page.$('#empty-text2')
      if (element2 != null) {
        const { width, height } = await element2.size()
        expect(width).toBe(0)
        expect(height).toBe(0)
      }
      await page.setData({
        autoTest: false
      })
36
  })
37

38
  it('nested text', async () => {
39 40 41
      await page.setData({
        autoTest: true
      })
42
      await page.callMethod("setNestedText")
43
      await page.waitFor(100)
44
      const element = await page.$('#nested-text')
45
      if (element != null) {
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
        expect(await element.text()).toBe("修改三级节点文本")
      }
      await page.setData({
        autoTest: false
      })
  })

  it('height text', async () => {
      await page.setData({
        autoTest: true
      })
      await page.callMethod("setHeightText")
      await page.waitFor(100)
      const element = await page.$('#height-text')
      if (element != null) {
        expect(await element.text()).toBe("修改设置高度文本")
62
      }
63 64 65
      await page.setData({
        autoTest: false
      })
66
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
67
})