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 27 28 29 30 31 32 33 34
      page.callMethod("setTextEmpty")
      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
      })
35
  })
36

雪洛's avatar
雪洛 已提交
37 38 39 40
  if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
    return
  }

41 42 43 44 45 46 47
  it('text nested', async () => {
      page.callMethod("setTextNested")
      const element = await page.$('#text-nested')
      if (element != null) {
        expect(await element.text()).toBe("二级节点文字红色且背景色黄色")
      }
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
48
})