readonly.test.js 2.2 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
const PAGE_PATH = '/pages/composition-api/reactivity/readonly/readonly'

describe('ref', () => {
  if (process.env.uniTestPlatformInfo.startsWith('android')) {
    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')
      expect(await dataArr.text()).toBe('data.arr: ["a","b","c"]')

      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')
      expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c"]')

      const updateDataBtn = await page.$('#update-data-btn')
      await updateDataBtn.tap()

      expect(await dataStr.text()).toBe('data.str: new str')
      expect(await dataNum.text()).toBe('data.num: 1')
      expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
      expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
      expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
      expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')

      const updateReadonlyDataBtn = await page.$('#update-readonly-data-btn')
      await updateReadonlyDataBtn.tap()

      expect(await dataStr.text()).toBe('data.str: new str')
      expect(await dataNum.text()).toBe('data.num: 1')
      expect(await dataArr.text()).toBe('data.arr: ["a","b","c","d"]')
      expect(await readonlyDataStr.text()).toBe('readonly data.str: new str')
      expect(await readonlyDataNum.text()).toBe('readonly data.num: 1')
      expect(await readonlyDataArr.text()).toBe('readonly data.arr: ["a","b","c","d"]')
    })
  } else {
    it('other platform', () => {
      expect(1).toBe(1)
    })
  }
})