picker-view.test.js 1.9 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
    await page.waitFor(1000)
雪洛's avatar
雪洛 已提交
19
    expect(await el.attribute('value')).toEqual([0, 0, 0])
Y
yurj26 已提交
20 21 22
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('result')).toEqual([0, 0, 0])
    }
Y
yurj26 已提交
23

Y
yurj26 已提交
24
    await page.callMethod('setValue1')
DCloud-WZF's avatar
DCloud-WZF 已提交
25
    await page.waitFor(1000)
雪洛's avatar
雪洛 已提交
26
    expect(await el.attribute('value')).toEqual([10, 10, 10])
Y
yurj26 已提交
27 28 29
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('result')).toEqual([10, 10, 10])
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
30
  })
Y
yurj26 已提交
31

DCloud-WZF's avatar
DCloud-WZF 已提交
32 33 34 35 36 37 38 39 40 41
  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;',
雪洛's avatar
雪洛 已提交
42
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
43
    await page.waitFor(500)
雪洛's avatar
雪洛 已提交
44
    expect(await el.attribute('indicatorStyle')).toBe('height: 100px;')
DCloud-WZF's avatar
DCloud-WZF 已提交
45 46 47 48 49 50
  })
  it('mask-top-style', async () => {
    const el = await page.$('.picker-view')
    await page.setData({
      maskTopStyle: 'background: #ffffff;',
    })
雪洛's avatar
雪洛 已提交
51
    expect(await el.attribute('mask-top-style')).toBe('background: #ffffff;')
DCloud-WZF's avatar
DCloud-WZF 已提交
52 53 54 55 56 57
  })
  it('mask-bottom-style', async () => {
    const el = await page.$('.picker-view')
    await page.setData({
      maskBottomStyle: 'background: #ffffff;',
    })
雪洛's avatar
雪洛 已提交
58
    expect(await el.attribute('mask-bottom-style')).toBe('background: #ffffff;')
DCloud-WZF's avatar
DCloud-WZF 已提交
59 60
  })
})