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

3 4
describe('reactive', () => {
	const isSafari = process.env.uniTestPlatformInfo.toLowerCase().indexOf('safari') > -1
雪洛's avatar
雪洛 已提交
5 6 7 8 9 10 11 12
  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')
DCloud-WZF's avatar
DCloud-WZF 已提交
13

雪洛's avatar
雪洛 已提交
14 15
    const objStr = await page.$('#obj-str')
    expect(await objStr.text()).toBe('obj.str: default str')
DCloud-WZF's avatar
DCloud-WZF 已提交
16

雪洛's avatar
雪洛 已提交
17 18
    const objNum = await page.$('#obj-num')
    expect(await objNum.text()).toBe('obj.num: 0')
DCloud-WZF's avatar
DCloud-WZF 已提交
19

雪洛's avatar
雪洛 已提交
20
    const objArr = await page.$('#obj-arr')
21
    expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ "a", "b", "c"]' : 'obj.arr: ["a","b","c"]')
DCloud-WZF's avatar
DCloud-WZF 已提交
22

23
    const updateBtn = await page.$('.update-btn')
雪洛's avatar
雪洛 已提交
24
    await updateBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
25

雪洛's avatar
雪洛 已提交
26 27 28
    expect(await count.text()).toBe('count: 2')
    expect(await objStr.text()).toBe('obj.str: new str')
    expect(await objNum.text()).toBe('obj.num: 2')
29
    expect(await objArr.text()).toBe(isSafari ? 'obj.arr: [ "a", "b", "c", "d"]' : 'obj.arr: ["a","b","c","d"]')
雪洛's avatar
雪洛 已提交
30
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
31
})