slider.test.js 1.6 KB
Newer Older
H
hdx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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 () => {
    const slider = await page.$('.slider-custom-color-and-size')

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

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

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

    const blockSize = 18
    await page.setData({
      sliderBlockSize: blockSize,
    })
    await page.waitFor(100)
雪洛's avatar
雪洛 已提交
49
    expect(await slider.attribute('blockSize')).toBe(blockSize)
H
hdx 已提交
50 51
  })
})