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

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

describe('Progress.uvue', () => {
    it('percent', async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
16
        await page.callMethod('setProgress')
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18
        await page.waitFor(1000);
        const p = await page.$('.p')
Y
yurj26 已提交
19
        expect(await p.property('percent')).toEqual(20)
DCloud-WZF's avatar
DCloud-WZF 已提交
20
        const p1 = await page.$('.p1')
Y
yurj26 已提交
21
        expect(await p1.property('percent')).toEqual(40)
DCloud-WZF's avatar
DCloud-WZF 已提交
22
        const p2 = await page.$('.p2')
Y
yurj26 已提交
23
        expect(await p2.property('percent')).toEqual(60)
DCloud-WZF's avatar
DCloud-WZF 已提交
24
        const p3 = await page.$('.p3')
Y
yurj26 已提交
25 26
        expect(await p3.property('percent')).toEqual(80)
        expect(await getData('curPercent')).toEqual(20)
DCloud-WZF's avatar
DCloud-WZF 已提交
27
        await page.callMethod('clearProgress')
Y
yurj26 已提交
28
        await page.waitFor(1000)
Y
yurj26 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
        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)
        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
        })
        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
        })
        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
        })
        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
        })
        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"
        })
        expect(await el.property('background-color')).toEqual('#007aff')
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
79
})