slider.test.js 1.7 KB
Newer Older
H
hdx 已提交
1 2 3 4 5 6 7 8 9 10
const PAGE_PATH = '/pages/component/slider/slider'

describe('slider', () => {
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(500)
  })
  // it('change', async () => {})
  it('value', async () => {
11
    const slider = await page.$('#slider-custom-color-and-size')
H
hdx 已提交
12 13 14 15 16 17

    const sliderValue = 80
    await page.setData({
      sliderValue: sliderValue,
    })
    await page.waitFor(100)
H
hdx 已提交
18 19 20
    // TODO
    const newValue = await slider.property('value')
    expect(newValue.toString()).toBe(sliderValue + '')
H
hdx 已提交
21 22
  })
  it('color', async () => {
23
    const slider = await page.$('#slider-custom-color-and-size')
雪洛's avatar
雪洛 已提交
24 25 26
    expect(await slider.attribute('backgroundColor')).toBe('#000000')
    expect(await slider.attribute('activeColor')).toBe('#FFCC33')
    expect(await slider.attribute('blockColor')).toBe('#8A6DE9')
H
hdx 已提交
27 28 29 30 31 32 33 34 35 36 37

    const backgroundColor = '#008000'
    const activeColor = '#00FF00'
    const blockColor = '#0000A0'

    await page.setData({
      sliderBackgroundColor: backgroundColor,
      sliderActiveColor: activeColor,
      sliderBlockColor: blockColor,
    })
    await page.waitFor(100)
雪洛's avatar
雪洛 已提交
38 39 40
    expect(await slider.attribute('backgroundColor')).toBe(backgroundColor)
    expect(await slider.attribute('activeColor')).toBe(activeColor)
    expect(await slider.attribute('blockColor')).toBe(blockColor)
H
hdx 已提交
41 42
  })
  it('block-size', async () => {
43
    const slider = await page.$('#slider-custom-color-and-size')
44
    expect(await slider.attribute('blockSize')).toBe(20 + '')
H
hdx 已提交
45 46 47 48 49 50

    const blockSize = 18
    await page.setData({
      sliderBlockSize: blockSize,
    })
    await page.waitFor(100)
51
    expect(await slider.attribute('blockSize')).toBe(blockSize + '')
H
hdx 已提交
52
  })
53
})