readonly.test.js 2.0 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly'

DCloud-WZF's avatar
DCloud-WZF 已提交
3
describe('ref', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8 9 10 11 12 13 14
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const dataStr = await page.$('#data-str')
    expect(await dataStr.text()).toBe('data.str: default str')
    const dataNum = await page.$('#data-num')
    expect(await dataNum.text()).toBe('data.num: 0')
    const dataArr = await page.$('#data-arr')
DCloud-WZF's avatar
DCloud-WZF 已提交
15
    expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
16

雪洛's avatar
雪洛 已提交
17 18 19 20 21
    const readonlyDataStr = await page.$('#readonly-data-str')
    expect(await readonlyDataStr.text()).toBe('readonly data.str: default str')
    const readonlyDataNum = await page.$('#readonly-data-num')
    expect(await readonlyDataNum.text()).toBe('readonly data.num: 0')
    const readonlyDataArr = await page.$('#readonly-data-arr')
DCloud-WZF's avatar
DCloud-WZF 已提交
22
    expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
23

雪洛's avatar
雪洛 已提交
24 25
    const updateDataBtn = await page.$('#update-data-btn')
    await updateDataBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
26

雪洛's avatar
雪洛 已提交
27 28
    expect(await dataStr.text()).toBe('data.str: new str')
    expect(await dataNum.text()).toBe('data.num: 1')
DCloud-WZF's avatar
DCloud-WZF 已提交
29
    expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
雪洛's avatar
雪洛 已提交
30 31
    expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
    expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
DCloud-WZF's avatar
DCloud-WZF 已提交
32
    expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
33

雪洛's avatar
雪洛 已提交
34 35
    const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn')
    await updateReadonlyDataBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
36

雪洛's avatar
雪洛 已提交
37 38
    expect(await dataStr.text()).toBe('data.str: new str')
    expect(await dataNum.text()).toBe('data.num: 1')
DCloud-WZF's avatar
DCloud-WZF 已提交
39
    expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
雪洛's avatar
雪洛 已提交
40 41
    expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
    expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
DCloud-WZF's avatar
DCloud-WZF 已提交
42
    expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
雪洛's avatar
雪洛 已提交
43
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
44
})