slider.test.js 2.0 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
    expect(await slider.attribute('activeBackgroundColor')).toBe('#FFCC33')
    expect(await slider.attribute('foreColor')).toBe('#8A6DE9')
H
hdx 已提交
29 30 31 32 33 34 35 36 37 38 39

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

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

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