reactive.test.js 1.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
const PAGE_PATH = '/pages/composition-api/reactivity/reactive/reactive'

describe('reactive', () => {
  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 count = await page.$('#count')
      expect(await count.text()).toBe('count: 0')

      const objStr = await page.$('#obj-str')
      expect(await objStr.text()).toBe('obj.str: default str')

      const objNum = await page.$('#obj-num')
      expect(await objNum.text()).toBe('obj.num: 0')

      const objArr = await page.$('#obj-arr')
      expect(await objArr.text()).toBe('obj.arr: ["a","b","c"]')

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

      expect(await count.text()).toBe('count: 2')
      expect(await objStr.text()).toBe('obj.str: new str')
      expect(await objNum.text()).toBe('obj.num: 2')
      expect(await objArr.text()).toBe('obj.arr: ["a","b","c","d"]')
    })
  } else {
    it('other platform', () => {
      expect(1).toBe(1)
    })
  }
})