v-memo.test.js 1.6 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
const PAGE_PATH = '/pages/directive/v-memo/v-memo'

describe('v-memo', () => {
  if (process.env.uniTestPlatformInfo.startsWith('android')) {
    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'
      )

      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'
      )

      const changeMessageBtn = await page.$('.change-message-btn')
      await changeMessageBtn.tap()

      const msg = await page.data('msg')
      expect(msg).toBe('msg changed')

      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'
      )

      const plusNumBtn = await page.$('.plus-num-btn')
      await plusNumBtn.tap()

      vMemoTextText = await vMemoTextEl.text()
      expect(vMemoTextText).toBe(
        'This will change when num change, msg: msg changed, num: 1'
      )
    })
  } else {
    // TODO: web 端暂不支持
    it('web', async () => {
      expect(1).toBe(1)
    })
  }
})