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

describe('toRefs', () => {
  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 stateNum = await page.$('#state-num')
      expect(await stateNum.text()).toBe('state.num: 0')
      const stateStr = await page.$('#state-str')
      expect(await stateStr.text()).toBe('state.str: str-0')
      const stateAsRefsNum = await page.$('#state-as-refs-num')
      expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 0')
      const stateAsRefsStr = await page.$('#state-as-refs-str')
      expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-0')

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

      expect(await stateNum.text()).toBe('state.num: 1')
      expect(await stateStr.text()).toBe('state.str: str-1')
      expect(await stateAsRefsNum.text()).toBe('stateAsRefs.num: 1')
      expect(await stateAsRefsStr.text()).toBe('stateAsRefs.str: str-1')
    })
  } else {
    it('other platform', () => {
      expect(1).toBe(1)
    })
  }
})