provide-composition.test.js 1.2 KB
Newer Older
1
const PAGE_PATH = '/pages/component-instance/provide/provide-composition'
2

3
describe('组合式 API provide', () => {
4 5 6 7 8 9 10 11 12 13 14 15 16
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('baisc', async () => {
    const msg = await page.$('.msg')
    expect(await msg.text()).toBe('msg: hello')

    const num = await page.$('.num')
    expect(await num.text()).toBe('num: 0')

    const obj = await page.$('.obj')
17
    expect(await obj.text()).toBe('obj: {"a":1}')
18 19 20

    const arr = await page.$('.arr')

21
    expect(await arr.text()).toBe('arr: [1,2,3]')
22

23 24 25 26
    const arr0 = await page.$('.arr-0')

    expect(await arr0.text()).toBe('arr[0]: 1')

27 28 29
    const fn = await page.$('.fn')
    expect(await fn.text()).toBe('fn: hello')

30 31
    const hasInjectionContext = await page.$('.has-injection-context')
    expect(await hasInjectionContext.text()).toBe('hasInjectionContext: true')
32

33 34
    const checkHasInjectionContextBtn = await page.$('.check-has-injection-context-btn')
    await checkHasInjectionContextBtn.tap()
35

36
    expect(await hasInjectionContext.text()).toBe('hasInjectionContext: false')
37 38
  })
})