progress.test.js 2.7 KB
Newer Older
Y
yurj26 已提交
1
function getData(key = '') {
Y
yurj26 已提交
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 () => {
Y
yurj26 已提交
10 11
  page = await program.reLaunch('/pages/component/progress/progress')
  await page.waitFor(2000);
Y
yurj26 已提交
12 13 14
})

describe('Progress.uvue', () => {
Y
yurj26 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  it('percent', async () => {
    await page.callMethod('setProgress')
    await page.waitFor(1000);
    const p = await page.$('.p')
    expect(await p.property('percent')).toEqual(20)
    const p1 = await page.$('.p1')
    expect(await p1.property('percent')).toEqual(40)
    const p2 = await page.$('.p2')
    expect(await p2.property('percent')).toEqual(60)
    const p3 = await page.$('.p3')
    expect(await p3.property('percent')).toEqual(80)
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('curPercent')).toEqual(20)
    }
    await page.callMethod('clearProgress')
    await page.waitFor(1000)
    expect(await p.property('percent')).toEqual(0)
    expect(await p1.property('percent')).toEqual(0)
    expect(await p2.property('percent')).toEqual(0)
    expect(await p3.property('percent')).toEqual(0)
    if (process.env.UNI_PLATFORM === 'app-android') {
      expect(await getData('curPercent')).toEqual(0)
    }
  })
  it('length', async () => {
    const elements = await page.$$('.progress')
    expect(elements.length).toBe(4)
  })
  it('show-info', async () => {
    const el = await page.$('.p')
    expect(await el.property('show-info')).toEqual(true)
    await page.setData({
      showInfo: false
Y
yurj26 已提交
48
    })
Y
yurj26 已提交
49 50 51 52 53 54 55
    expect(await el.property('show-info')).toEqual(false)
  })
  it('border-radius', async () => {
    const el = await page.$('.p')
    expect(await el.property('border-radius')).toEqual(0)
    await page.setData({
      borderRadius: 5
Y
yurj26 已提交
56
    })
Y
yurj26 已提交
57 58 59 60 61 62 63
    expect(await el.property('border-radius')).toEqual(5)
  })
  it('font-size', async () => {
    const el = await page.$('.p')
    expect(await el.property('font-size')).toEqual(16)
    await page.setData({
      fontSize: 18
Y
yurj26 已提交
64
    })
Y
yurj26 已提交
65 66 67 68 69 70 71
    expect(await el.property('font-size')).toEqual(18)
  })
  it('stroke-width', async () => {
    const el = await page.$('.p')
    expect(await el.property('stroke-width')).toEqual(3)
    await page.setData({
      strokeWidth: 6
Y
yurj26 已提交
72
    })
Y
yurj26 已提交
73 74 75 76 77 78 79
    expect(await el.property('stroke-width')).toEqual(6)
  })
  it('backgroundColor', async () => {
    const el = await page.$('.p')
    expect(await el.property('background-color')).toEqual('#EBEBEB')
    await page.setData({
      backgroundColor: "#007aff"
Y
yurj26 已提交
80
    })
Y
yurj26 已提交
81 82 83
    expect(await el.property('background-color')).toEqual('#007aff')
  })
})