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

describe('toValue', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7
  if (process.env.uniTestPlatformInfo.startsWith('web')) {
    // TODO: web 端暂不支持
    it('web', async () => {
      expect(1).toBe(1)
DCloud-WZF's avatar
DCloud-WZF 已提交
8
    })
雪洛's avatar
雪洛 已提交
9
    return
雪洛's avatar
雪洛 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  }
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const refCount = await page.$('#ref-count')
    expect(await refCount.text()).toBe('ref count: 0')
    const isRefRefCount = await page.$('#is-ref-ref-count')
    expect(await isRefRefCount.text()).toBe('isRef ref count: true')
    const count = await page.$('#count')
    expect(await count.text()).toBe('count: 0')
    const isRefCount = await page.$('#is-ref-count')
    expect(await isRefCount.text()).toBe('isRef count: false')
DCloud-WZF's avatar
DCloud-WZF 已提交
25

雪洛's avatar
雪洛 已提交
26 27 28 29
    const objNum = await page.$('#obj-num')
    expect(await objNum.text()).toBe('obj.num: 0')
    const toValueObjNum = await page.$('#to-value-obj-num')
    expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 0')
DCloud-WZF's avatar
DCloud-WZF 已提交
30

雪洛's avatar
雪洛 已提交
31 32
    const incrementBtn = await page.$('#increment-btn')
    await incrementBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
33

雪洛's avatar
雪洛 已提交
34 35 36
    expect(await objNum.text()).toBe('obj.num: 1')
    expect(await toValueObjNum.text()).toBe('toValue(() => obj.num): 1')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
37
})