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

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

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

雪洛's avatar
雪洛 已提交
16
    const objNum = await page.$('#obj-num')
DCloud-WZF's avatar
DCloud-WZF 已提交
17
    expect(await objNum.text()).toBe('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('["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

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