picker-view.test.js 2.0 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')
18 19 20 21
    await page.waitFor(1000)
    const newValue1 = await el.property('value')
    // TODO
    expect(newValue1.toString()).toEqual('0,0,0')
Y
yurj26 已提交
22 23 24
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('result')).toEqual([0, 0, 0])
    }
Y
yurj26 已提交
25

Y
yurj26 已提交
26
    await page.callMethod('setValue1')
27 28 29 30
    await page.waitFor(1000)
    const newValue2 = await el.property('value')
    // TODO
    expect(newValue2.toString()).toEqual('10,10,10')
Y
yurj26 已提交
31 32 33
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('result')).toEqual([10, 10, 10])
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
34
  })
Y
yurj26 已提交
35

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