v-memo.test.js 1.4 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const PAGE_PATH = '/pages/directive/v-memo/v-memo'

describe('v-memo', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8 9 10 11 12 13 14
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const equivalentVOnceTextEl = await page.$('.equivalent-v-once-text')
    let equivalentVOnceTextText = await equivalentVOnceTextEl.text()
    expect(equivalentVOnceTextText).toBe(
      'This will never change: hello world'
    )
DCloud-WZF's avatar
DCloud-WZF 已提交
15

雪洛's avatar
雪洛 已提交
16 17 18 19 20
    const vMemoTextEl = await page.$('.v-memo-text')
    let vMemoTextText = await vMemoTextEl.text()
    expect(vMemoTextText).toBe(
      'This will change when num change, msg: hello world, num: 0'
    )
DCloud-WZF's avatar
DCloud-WZF 已提交
21

雪洛's avatar
雪洛 已提交
22 23
    const changeMessageBtn = await page.$('.change-message-btn')
    await changeMessageBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
24

雪洛's avatar
雪洛 已提交
25 26
    const msg = await page.data('msg')
    expect(msg).toBe('msg changed')
DCloud-WZF's avatar
DCloud-WZF 已提交
27

雪洛's avatar
雪洛 已提交
28 29 30 31 32 33 34 35
    equivalentVOnceTextText = await equivalentVOnceTextEl.text()
    expect(equivalentVOnceTextText).toBe(
      'This will never change: hello world'
    )
    vMemoTextText = await vMemoTextEl.text()
    expect(vMemoTextText).toBe(
      'This will change when num change, msg: hello world, num: 0'
    )
DCloud-WZF's avatar
DCloud-WZF 已提交
36

雪洛's avatar
雪洛 已提交
37 38
    const plusNumBtn = await page.$('.plus-num-btn')
    await plusNumBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
39

雪洛's avatar
雪洛 已提交
40 41 42 43 44
    vMemoTextText = await vMemoTextEl.text()
    expect(vMemoTextText).toBe(
      'This will change when num change, msg: msg changed, num: 1'
    )
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
45
})