v-memo.test.js 1.5 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2
const OPTIONS_PAGE_PATH = '/pages/directive/v-memo/v-memo-options'
const COMPOSITION_PAGE_PATH = '/pages/directive/v-memo/v-memo-composition'
DCloud-WZF's avatar
DCloud-WZF 已提交
3 4

describe('v-memo', () => {
雪洛's avatar
雪洛 已提交
5 6 7 8 9 10 11
  if (process.env.uniTestPlatformInfo.startsWith('web')) {
    // TODO: web 暂不支持
    it('web', async () => {
      expect(1).toBe(1)
    })
    return
  }
雪洛's avatar
雪洛 已提交
12
  let page
DCloud-WZF's avatar
DCloud-WZF 已提交
13 14
  const test = async (pagePath) => {
    page = await program.reLaunch(pagePath)
雪洛's avatar
雪洛 已提交
15
    await page.waitFor('view')
DCloud-WZF's avatar
DCloud-WZF 已提交
16 17 18
    
    const neverChangeMsg = await page.$('#v-memo-never-change-msg')
    expect(await neverChangeMsg.text()).toBe('hello world')
DCloud-WZF's avatar
DCloud-WZF 已提交
19

DCloud-WZF's avatar
DCloud-WZF 已提交
20 21 22 23 24
    const msg = await page.$('#msg')
    expect(await msg.text()).toBe('hello world')
    
    const numChangeMsg = await page.$('#v-memo-num-change-msg')
    expect(await numChangeMsg.text()).toBe('hello world')
DCloud-WZF's avatar
DCloud-WZF 已提交
25

DCloud-WZF's avatar
DCloud-WZF 已提交
26
    const changeMessageBtn = await page.$('#change-message-btn')
雪洛's avatar
雪洛 已提交
27
    await changeMessageBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
28

DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31
    expect(await neverChangeMsg.text()).toBe('hello world')
    expect(await msg.text()).toBe('msg changed')
    expect(await numChangeMsg.text()).toBe('hello world')
DCloud-WZF's avatar
DCloud-WZF 已提交
32

DCloud-WZF's avatar
DCloud-WZF 已提交
33 34
    const incrementNumBtn = await page.$('#increment-num-btn')
    await incrementNumBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
35

DCloud-WZF's avatar
DCloud-WZF 已提交
36 37 38 39 40 41 42 43 44 45 46 47
    expect(await neverChangeMsg.text()).toBe('hello world')
    expect(await msg.text()).toBe('msg changed')
    expect(await numChangeMsg.text()).toBe('msg changed')
  }
  
  it('v-memo options API', async () => {
		await test(OPTIONS_PAGE_PATH)
	})
	
	it('v-memo composition API', async () => {
		await test(COMPOSITION_PAGE_PATH)
	})
DCloud-WZF's avatar
DCloud-WZF 已提交
48
})