text-props.test.js 1.3 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 12 13
  it('screenshot', async () => {
    const image = await program.screenshot({ fullPage: true })
    expect(image).toMatchImageSnapshot()
  })
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 26
      await page.callMethod("setTextEmpty")
      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('text nested', async () => {
39 40 41 42 43
      await page.setData({
        autoTest: true
      })
      await page.callMethod("setTextNested")
      await page.waitFor(100)
44 45
      const element = await page.$('#text-nested')
      if (element != null) {
46
        expect(await element.text()).toBe("修改三级节点")
47
      }
48 49 50
      await page.setData({
        autoTest: false
      })
51
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
52
})