provide-page2.test.js 3.1 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
const PAGE_PATH = '/pages/composition/provide/provide-page2'
2 3
describe('函数方式创建 provide', () => {
	const isSafari = process.env.uniTestPlatformInfo.toLowerCase().indexOf('safari') > -1
雪洛's avatar
雪洛 已提交
4
  const isWeb = process.env.uniTestPlatformInfo.startsWith('web')
雪洛's avatar
雪洛 已提交
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('variable', async () => {
    const providePageTitleEl = await page.$('.provide-page-title')
    const providePageTitleText = await providePageTitleEl.text()
    expect(providePageTitleText).toBe(
      'providePageTitle: 函数方式定义 provide page title'
    )
  })
  it('string', async () => {
    const providePageStrEl = await page.$('.provide-page-str')
    const providePageStrText = await providePageStrEl.text()
    expect(providePageStrText).toBe(
      'providePageStr: 函数方式定义 provide page str'
    )
  })
  it('number', async () => {
    const providePageNumEl = await page.$('.provide-page-num')
    const providePageNumText = await providePageNumEl.text()
    expect(providePageNumText).toBe('providePageNum: 2')
  })
  it('boolean', async () => {
    const providePageBoolEl = await page.$('.provide-page-bool')
    const providePageBoolText = await providePageBoolEl.text()
    expect(providePageBoolText).toBe('providePageBool: true')
  })
  it('object', async () => {
    const providePageObjectTitleEl = await page.$(
      '.provide-page-object-title'
    )
    const providePageObjectTitleText = await providePageObjectTitleEl.text()
    expect(providePageObjectTitleText).toBe(
      'providePageObject.title: 函数方式定义 provide page object title'
    )
    const providePageObjectContentEl = await page.$(
      '.provide-page-object-content'
    )
    const providePageObjectContentText =
      await providePageObjectContentEl.text()
    expect(providePageObjectContentText).toBe(
      'providePageObject.content: 函数方式定义 provide page object content'
    )
  })
  it('array', async () => {
    const providePageArrEl = await page.$('.provide-page-arr')
    const providePageArrText = await providePageArrEl.text()
    expect(providePageArrText).toBe(
55
      isSafari ? 'providePageArr: [ "函数方式定义 provide page arr"]' : 'providePageArr: ["函数方式定义 provide page arr"]'
雪洛's avatar
雪洛 已提交
56 57 58 59 60 61
    )
  })
  it('map', async () => {
    const providePageMapEl = await page.$('.provide-page-map')
    const providePageMapText = await providePageMapEl.text()
    expect(providePageMapText).toBe(
62
      isWeb ? (isSafari ? 'providePageMap: { "key": "函数方式定义 provide page map"}' : 'providePageMap: {"key": "函数方式定义 provide page map"}') : 'providePageMap: {"key":"函数方式定义 provide page map"}'
雪洛's avatar
雪洛 已提交
63 64 65 66 67 68
    )
  })
  it('set', async () => {
    const providePageSetEl = await page.$('.provide-page-set')
    const providePageSetText = await providePageSetEl.text()
    expect(providePageSetText).toBe(
69
      isSafari ? 'providePageSet: [ "函数方式定义 provide page set"]' : 'providePageSet: ["函数方式定义 provide page set"]'
雪洛's avatar
雪洛 已提交
70 71
    )
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
72
})