props.test.js 1.9 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
const OPTIONS_PAGE_PATH = '/pages/component-instance/props/props-options'
const COMPOSITION_PAGE_PATH = '/pages/component-instance/props/props-composition'
3

DCloud-WZF's avatar
DCloud-WZF 已提交
4
describe('props', () => {
5
  let page
DCloud-WZF's avatar
DCloud-WZF 已提交
6
  const test = async (page) => {
7
    const arrayLiteralStr = await page.$('#array-literal-str')
DCloud-WZF's avatar
DCloud-WZF 已提交
8 9
    expect(await arrayLiteralStr.text()).toBe('str')
    
10
    const arrayLiteralNum = await page.$('#array-literal-num')
DCloud-WZF's avatar
DCloud-WZF 已提交
11 12
    expect(await arrayLiteralNum.text()).toBe('10')
    
13 14
    const arrayLiteralBool = await page.$('#array-literal-bool')
    expect(await arrayLiteralBool.text()).toBe('true')
DCloud-WZF's avatar
DCloud-WZF 已提交
15
    
16
    const arrayLiteralObj = await page.$('#array-literal-obj')
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18
    expect(await arrayLiteralObj.text()).toBe('{"age":18}')
    
19
    const arrayLiteralArr = await page.$('#array-literal-arr')
DCloud-WZF's avatar
DCloud-WZF 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    expect(await arrayLiteralArr.text()).toBe('["a","b","c"]')
    
    const objectTypeStr = await page.$('#object-type-str')
    expect(await objectTypeStr.text()).toBe('str')
    
    const objectTypeNum = await page.$('#object-type-num')
    expect(await objectTypeNum.text()).toBe('10')
    
    const objectTypeBool = await page.$('#object-type-bool')
    expect(await objectTypeBool.text()).toBe('true')
    
    const objectTypeObj = await page.$('#object-type-obj')
    expect(await objectTypeObj.text()).toBe('{"age":18}')
    
    const objectTypeArr = await page.$('#object-type-arr')
    expect(await objectTypeArr.text()).toBe('["a","b","c"]')
    
    const sameNamePropDefaultValueArr = await page.$('#same-name-prop-default-value-arr')
    expect(await sameNamePropDefaultValueArr.text()).toBe('[1,2,3]')
  }
40

DCloud-WZF's avatar
DCloud-WZF 已提交
41 42 43 44
  it('props 选项式 API', async () => {
    page = await program.reLaunch(OPTIONS_PAGE_PATH)
    await test(page)
  });
45

DCloud-WZF's avatar
DCloud-WZF 已提交
46 47 48
  it('props 组合式 API', async () => {
    page = await program.reLaunch(COMPOSITION_PAGE_PATH)
    await test(page)
49 50
  })
})