switch.test.js 1.5 KB
Newer Older
H
hdx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
const PAGE_PATH = '/pages/component/switch/switch'

describe('switch', () => {
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(500)
  })
  // TODO
  // it('click', async () => {
  //   const switch_element = await page.$('.switch-checked')
  //   const switch_element_value = await page.$('.switch-checked-value')
  //   expect(await switch_element_value.text()).toBe('true')

  //   await page.waitFor(200)

  //   await switch_element.tap()
  //   await page.waitFor(200)
  //   expect(await switch_element_value.text()).toBe('false')

  //   await switch_element.tap()
  //   await page.waitFor(200)
  //   expect(await switch_element_value.text()).toBe('true')
  // })
  it('checked', async () => {
    const switch_element = await page.$('.switch-checked')

    await page.setData({
      checked: false,
    })
    await page.waitFor(100)
H
hdx 已提交
32 33 34
    // TODO
    const newValue1 = await switch_element.property('checked')
    expect(newValue1.toString()).toBe(false + '')
H
hdx 已提交
35 36 37 38 39

    await page.setData({
      checked: true,
    })
    await page.waitFor(100)
H
hdx 已提交
40 41 42
    // TODO
    const newValue2 = await switch_element.property('checked')
    expect(newValue2.toString()).toBe(true + '')
H
hdx 已提交
43 44 45
  })
  it('color', async () => {
    const switch_element = await page.$('.switch-color')
雪洛's avatar
雪洛 已提交
46
    expect(await switch_element.attribute('color')).toBe('#FFCC33')
H
hdx 已提交
47 48 49 50 51 52 53

    const color = '#00ff00'

    await page.setData({
      color: color
    })
    await page.waitFor(100)
雪洛's avatar
雪洛 已提交
54
    expect(await switch_element.attribute('color')).toBe(color)
H
hdx 已提交
55
  })
56
})