define-model.test.js 1.4 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
const PAGE_PATH = '/pages/composition-api/basic/define-model/define-model'

describe('defineModel', () => {
雪洛's avatar
雪洛 已提交
4 5 6 7 8
  if (process.env.uniTestPlatformInfo.startsWith('web')) {
    // TODO: web 端暂不支持
    it('web', async () => {
      expect(1).toBe(1)
    })
雪洛's avatar
雪洛 已提交
9
    return
雪洛's avatar
雪洛 已提交
10
  }
雪洛's avatar
雪洛 已提交
11 12 13 14 15 16 17 18
  let page = null
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor('view')
  })
  it('basic', async () => {
    const modelValueText = await page.$('#model-value-text')
    expect(await modelValueText.text()).toBe('modelValue in Foo: str')
DCloud-WZF's avatar
DCloud-WZF 已提交
19

雪洛's avatar
雪洛 已提交
20 21
    const modelValueInput = await page.$('#model-value-input')
    expect(await modelValueInput.property('value')).toBe('str')
DCloud-WZF's avatar
DCloud-WZF 已提交
22

23 24 25 26 27
    const msgText = await page.$('#msg-text')
    expect(await msgText.text()).toBe('msg in Foo: msg')
    
    const defaultNumText = await page.$('#default-num-text')
    expect(await defaultNumText.text()).toBe('num: 10')
DCloud-WZF's avatar
DCloud-WZF 已提交
28

雪洛's avatar
雪洛 已提交
29 30
    const msgInput = await page.$('#msg-input')
    expect(await msgInput.property('value')).toBe('msg')
DCloud-WZF's avatar
DCloud-WZF 已提交
31

雪洛's avatar
雪洛 已提交
32 33
    const updateValueBtn = await page.$('#update-value-btn')
    await updateValueBtn.tap()
DCloud-WZF's avatar
DCloud-WZF 已提交
34

雪洛's avatar
雪洛 已提交
35 36
    expect(await modelValueText.text()).toBe('modelValue in Foo: str1')
    expect(await modelValueInput.property('value')).toBe('str1')
DCloud-WZF's avatar
DCloud-WZF 已提交
37

雪洛's avatar
雪洛 已提交
38 39 40
    expect(await msgText.text()).toBe('msg in Foo: msg2')
    expect(await msgInput.property('value')).toBe('msg2')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
41
})