picker-view.test.js 1.7 KB
Newer Older
Y
yurj26 已提交
1
function getData(key = '') {
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5
  return new Promise(async (resolve, reject) => {
    const data = await page.data()
    resolve(key ? data[key] : data)
  })
Y
yurj26 已提交
6 7 8 9
}

let page
beforeAll(async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
10
  page = await program.reLaunch('/pages/component/picker-view/picker-view')
Y
yurj26 已提交
11
  await page.waitFor('view')
Y
yurj26 已提交
12 13 14
})

describe('PickerView.uvue', () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
15 16
  it('value', async () => {
    const el = await page.$('.picker-view')
Y
yurj26 已提交
17
    await page.callMethod('setValue')
DCloud-WZF's avatar
DCloud-WZF 已提交
18 19 20
    await page.waitFor(1000)
    expect(await el.property('value')).toEqual([0, 0, 0])
    expect(await getData('result')).toEqual([0, 0, 0])
Y
yurj26 已提交
21

Y
yurj26 已提交
22
    await page.callMethod('setValue1')
DCloud-WZF's avatar
DCloud-WZF 已提交
23 24 25 26
    await page.waitFor(1000)
    expect(await el.property('value')).toEqual([10, 10, 10])
    expect(await getData('result')).toEqual([10, 10, 10])
  })
Y
yurj26 已提交
27

DCloud-WZF's avatar
DCloud-WZF 已提交
28 29 30 31 32 33 34 35 36 37
  it('length', async () => {
    const els = await page.$$('.picker-view')
    expect(els.length).toBe(1)
    const els1 = await page.$$('.picker-view-column')
    expect(els1.length).toBe(3)
  })
  it('indicator-style', async () => {
    const el = await page.$('.picker-view')
    await page.setData({
      indicatorStyle: 'height: 100px;',
Y
yurj26 已提交
38
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    await page.waitFor(500)
    expect(await el.property('indicatorStyle')).toBe('height: 100px;')
  })
  it('mask-top-style', async () => {
    const el = await page.$('.picker-view')
    await page.setData({
      maskTopStyle: 'background: #ffffff;',
    })
    expect(await el.property('mask-top-style')).toBe('background: #ffffff;')
  })
  it('mask-bottom-style', async () => {
    const el = await page.$('.picker-view')
    await page.setData({
      maskBottomStyle: 'background: #ffffff;',
    })
    expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;')
  })
})