render.test.js 1.5 KB
Newer Older
1 2
const OPTIONS_PAGE_PATH = '/pages/render-function/render/render-options'
const COMPOSITION_PAGE_PATH = '/pages/render-function/render/render-composition'
DCloud-WZF's avatar
DCloud-WZF 已提交
3

4 5 6 7 8 9 10 11
describe('render-function render', () => {
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  const isWeb = platformInfo.startsWith('web')
  const isIos = platformInfo.startsWith('ios')
  if (isWeb) {
    it("web platform test cannot get render dom", async () => {
      expect(1).toBe(1);
    });
DCloud-WZF's avatar
DCloud-WZF 已提交
12 13 14
    return
  }
  let page
15 16
  const test = async (pagePath) => {
    page = await program.reLaunch(pagePath)
DCloud-WZF's avatar
DCloud-WZF 已提交
17
    await page.waitFor('view')
18
    
DCloud-WZF's avatar
DCloud-WZF 已提交
19 20 21 22 23 24
    const ComForRenderFunction = await page.$('.component-for-h-function')
    expect(await ComForRenderFunction.text()).toEqual(
      'component for h()'
    )
    const compSlot = await page.$('.comp-slot')
    expect(await compSlot.text()).toEqual('component slot')
25 26
    
    let msgEl = await page.$('.msg')
DCloud-WZF's avatar
DCloud-WZF 已提交
27
    expect(await msgEl.text()).toEqual('default msg')
28
    
DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31
    const btnEl = await page.$('.btn')
    expect(await btnEl.property('type')).toBe('primary')
    await btnEl.tap()
32
    msgEl = await page.$('.msg')
DCloud-WZF's avatar
DCloud-WZF 已提交
33
    expect(await msgEl.text()).toEqual('new msg')
34 35 36 37 38 39 40 41 42 43 44 45 46
  }
  
  it('render options API', async () => {
    await test(OPTIONS_PAGE_PATH)
  })

  it('render composition API', async () => {
    if (!isIos) {
      await test(COMPOSITION_PAGE_PATH)
    } else {
      // TODO: ios 端 defineOptions + render 页面空白
      expect(1).toBe(1);
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
47 48
  })
})