button.js 2.3 KB
Newer Older
1
/* function getData(key = '') {
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5
  return new Promise(async (resolve, reject) => {
    const data = await page.data()
    resolve(key ? data[key] : data)
  })
Y
yurj26 已提交
6 7 8 9
}

let page
beforeAll(async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
10 11
  page = await program.reLaunch('/pages/component/button/button')
  await page.waitFor(1000)
12 13
})*/

Y
yurj26 已提交
14 15

describe('Button.uvue', () => {
16 17
	// TODO BUTTON TEST
  /* it('click', async () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30
    const defaultBtn = await page.$('.default-button')
    const disabledBtn = await page.$('.disabled-button')
    expect(await getData('count')).toEqual(0)
    await defaultBtn.tap()
    expect(await getData('count')).toEqual(1)
    await disabledBtn.tap()
    expect(await getData('count')).toEqual(1)
  })
  it('length', async () => {
    const elements = await page.$$('.button')
    expect(elements.length).toBe(13)
  })
  it('text', async () => {
Y
yurj26 已提交
31 32
    const textBtn = await page.$('.text-button')
    expect(await textBtn.text()).toEqual('文字来自data绑定')
DCloud-WZF's avatar
DCloud-WZF 已提交
33 34
    await page.setData({
      text: 'button',
Y
yurj26 已提交
35
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
36 37 38 39 40 41 42
    expect(await textBtn.text()).toEqual('button')
  })
  it('type', async () => {
    const btn = await page.$('.test-button')
    expect(await btn.property('type')).toBe('primary')
    await page.setData({
      type: 'default',
Y
yurj26 已提交
43
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
44 45 46 47
    await page.waitFor(500)
    expect(await btn.property('type')).toBe('default')
    await page.setData({
      type: 'warn',
Y
yurj26 已提交
48
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
49 50 51 52 53 54 55 56
    await page.waitFor(500)
    expect(await btn.property('type')).toBe('warn')
  })
  it('size', async () => {
    const btn = await page.$('.test-button')
    expect(await btn.property('size')).toBe('default')
    await page.setData({
      size: 'mini',
Y
yurj26 已提交
57
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
58 59 60 61 62 63 64 65
    await page.waitFor(500)
    expect(await btn.property('size')).toBe('mini')
  })
  it('plain', async () => {
    const btn = await page.$('.test-button')
    expect(await btn.property('plain')).toBe(false)
    await page.setData({
      plain: true,
Y
yurj26 已提交
66
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
67 68 69 70 71 72 73 74
    await page.waitFor(500)
    expect(await btn.property('plain')).toBe(true)
  })
  it('disabled', async () => {
    const btn = await page.$('.test-button')
    expect(await btn.property('disabled')).toBe(false)
    await page.setData({
      disabled: true,
Y
yurj26 已提交
75
    })
DCloud-WZF's avatar
DCloud-WZF 已提交
76 77
    await page.waitFor(500)
    expect(await btn.property('disabled')).toBe(true)
78
  }) */
DCloud-WZF's avatar
DCloud-WZF 已提交
79
})