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

3 4
describe('ref', () => {
	const isSafari = process.env.uniTestPlatformInfo.indexOf('safari') > -1
雪洛's avatar
雪洛 已提交
5 6 7 8 9 10 11 12 13 14 15
  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')
16
    expect(await dataArr.text()).toBe(isSafari ? 'data.arr: [ "a", "b", "c"]' : 'data.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
17

雪洛's avatar
雪洛 已提交
18 19 20 21 22
    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')
23
    expect(await readonlyDataArr.text()).toBe(isSafari ? 'readonly data.arr: [ "a", "b", "c"]' : 'readonly data.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
24

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

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

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

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