define-model.test.js 1.1 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 10 11
  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 已提交
12

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

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

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

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

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

雪洛's avatar
雪洛 已提交
28 29 30
    expect(await msgText.text()).toBe('msg in Foo: msg2')
    expect(await msgInput.property('value')).toBe('msg2')
  })
DCloud-WZF's avatar
DCloud-WZF 已提交
31
})