define-props.test.js 3.1 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
const PAGE_PATH = '/pages/composition-api/basic/define-props/define-props'

DCloud-WZF's avatar
DCloud-WZF 已提交
3
describe('defineProps', () => {
4 5 6 7 8 9 10 11 12 13 14 15
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const arrayLiteralStr = await page.$('#array-literal-str')
    expect(await arrayLiteralStr.text()).toBe('str: default str')
    const arrayLiteralNum = await page.$('#array-literal-num')
    expect(await arrayLiteralNum.text()).toBe('num: 0')
    const arrayLiteralBool = await page.$('#array-literal-bool')
    expect(await arrayLiteralBool.text()).toBe('bool: false')
DCloud-WZF's avatar
DCloud-WZF 已提交
16
    const arrayLiteralArr = await page.$('#array-literal-arr')
17
    expect(await arrayLiteralArr.text()).toBe('arr: ["a","b","c"]')
18 19 20
    
    const arrayLiteralObj = await page.$('#array-literal-obj')
    if (process.env.uniTestPlatformInfo.startsWith('android')) {
DCloud-WZF's avatar
DCloud-WZF 已提交
21
      expect(await arrayLiteralObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}')
22
    }
23 24
    if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
      expect(await arrayLiteralObj.text()).toBe('obj: {"str":"obj str","num":0,"arr":[1,2,3]}')
25
    }
26
    
27 28 29 30 31 32 33 34 35 36
    const arrayLiteralFn = await page.$('#array-literal-fn')
    expect(await arrayLiteralFn.text()).toBe('fn: fn res')

    const objectLiteralStr = await page.$('#object-literal-str')
    expect(await objectLiteralStr.text()).toBe('str: default str')
    const objectLiteralNum = await page.$('#object-literal-num')
    expect(await objectLiteralNum.text()).toBe('num: 0')
    const objectLiteralBool = await page.$('#object-literal-bool')
    expect(await objectLiteralBool.text()).toBe('bool: false')
    const objectLiteralArr = await page.$('#object-literal-arr')
37
    expect(await objectLiteralArr.text()).toBe('arr: ["a","b","c"]')
38 39
    
    const objectLiteralObj = await page.$('#object-literal-obj')
40
    expect(await objectLiteralObj.text()).toBe('obj: {"a":1}')
41 42 43
    
    const objectLiteralFn = await page.$('#object-literal-fn')
    expect(await objectLiteralFn.text()).toBe('fn: fn res')
DCloud-WZF's avatar
DCloud-WZF 已提交
44

45 46 47 48 49 50 51
    const typeStr = await page.$('#type-str')
    expect(await typeStr.text()).toBe('str: default str')
    const typeNum = await page.$('#type-num')
    expect(await typeNum.text()).toBe('num: 0')
    const typeBool = await page.$('#type-bool')
    expect(await typeBool.text()).toBe('bool: false')
    const typeArr = await page.$('#type-arr')
52
    expect(await typeArr.text()).toBe('arr: ["a","b","c"]')
53 54 55
    
    const typeObj = await page.$('#type-obj')
    if (process.env.uniTestPlatformInfo.startsWith('android')) {
DCloud-WZF's avatar
DCloud-WZF 已提交
56
      expect(await typeObj.text()).toBe('obj: {"arr":[1,2,3],"num":0,"str":"obj str"}')
57
    }
58
    if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
59
      expect(await typeObj.text()).toBe('obj: {"str":"obj str","num":0,"arr":[1,2,3]}')
60 61 62 63
    }
    const typeFn = await page.$('#type-fn')
    expect(await typeFn.text()).toBe('fn: fn res')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
64
})