define-model.test.js 1.2 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 9
  if (process.env.uniTestPlatformInfo.startsWith('web')) {
    // TODO: web 端暂不支持
    it('web', async () => {
      expect(1).toBe(1)
    })
  }
雪洛's avatar
雪洛 已提交
10 11 12 13 14 15 16 17
  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 已提交
18

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

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

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

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

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

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