provide-inject.test.js 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
const PAGE_PATH = '/pages/composition-api/dependency-injection/provide/provide'

describe('provide-inject-hasInjectionContext', () => {
  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')
    expect(await obj.text()).toBe('obj: {"a":1}')

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

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

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

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

    const checkHasInjectionContextBtn = await page.$('.check-has-injection-context-btn')
    await checkHasInjectionContextBtn.tap()
    
    expect(await hasInjectionContext.text()).toBe('hasInjectionContext: false')
  })
})