define-model.test.js 1.3 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

雪洛's avatar
雪洛 已提交
23 24
    const msgText = await page.$('#msg-text')
    expect(await msgText.text()).toBe('msg in Foo: msg')
DCloud-WZF's avatar
DCloud-WZF 已提交
25

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

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

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

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