reactive.test.js 991 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const PAGE_PATH = '/pages/composition-api/reactivity/reactive/reactive'

describe('reactive', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8 9 10 11
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const count = await page.$('#count')
    expect(await count.text()).toBe('count: 0')
DCloud-WZF's avatar
DCloud-WZF 已提交
12

雪洛's avatar
雪洛 已提交
13 14
    const objStr = await page.$('#obj-str')
    expect(await objStr.text()).toBe('obj.str: default str')
DCloud-WZF's avatar
DCloud-WZF 已提交
15

雪洛's avatar
雪洛 已提交
16 17
    const objNum = await page.$('#obj-num')
    expect(await objNum.text()).toBe('obj.num: 0')
DCloud-WZF's avatar
DCloud-WZF 已提交
18

雪洛's avatar
雪洛 已提交
19
    const objArr = await page.$('#obj-arr')
DCloud-WZF's avatar
DCloud-WZF 已提交
20
    expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
21

22
    const updateBtn = await page.$('.update-btn')
雪洛's avatar
雪洛 已提交
23
    await updateBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
24

雪洛's avatar
雪洛 已提交
25 26 27
    expect(await count.text()).toBe('count: 2')
    expect(await objStr.text()).toBe('obj.str: new str')
    expect(await objNum.text()).toBe('obj.num: 2')
DCloud-WZF's avatar
DCloud-WZF 已提交
28
    expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]')
雪洛's avatar
雪洛 已提交
29
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
30
})