provide-inject.test.js 1.4 KB
Newer Older
1 2
const PAGE_PATH = '/pages/composition-api/dependency-injection/provide/provide'

3 4
describe('provide-inject-hasInjectionContext', () => {
	const isSafari = process.env.uniTestPlatformInfo.toLowerCase().indexOf('safari') > -1
雪洛's avatar
雪洛 已提交
5
  const isWeb = process.env.uniTestPlatformInfo.startsWith('web')
6 7 8 9 10 11 12 13 14 15 16 17 18
  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')
19
    expect(await obj.text()).toBe(isWeb ? (isSafari ? 'obj: { "a": 1}' : 'obj: {"a": 1}') : 'obj: {"a":1}')
20 21 22

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

23
    expect(await arr.text()).toBe(isSafari ? 'arr: [ 1, 2, 3]' : 'arr: [1,2,3]')
24 25 26 27

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

28 29 30
    if (process.env.uniTestPlatformInfo.startsWith('android')) {
      const hasInjectionContext = await page.$('.has-injection-context')
      expect(await hasInjectionContext.text()).toBe('hasInjectionContext: true')
31

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

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