define-model.test.js 1.3 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
const PAGE_PATH = '/pages/composition-api/basic/define-model/define-model'

describe('defineModel', () => {
  if (process.env.uniTestPlatformInfo.startsWith('android')) {
    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')

      const modelValueInput = await page.$('#model-value-input')
      expect(await modelValueInput.property('value')).toBe('str')

      const msgText = await page.$('#msg-text')
      expect(await msgText.text()).toBe('msg in Foo: msg')

      const msgInput = await page.$('#msg-input')
      expect(await msgInput.property('value')).toBe('msg')

      const updateValueBtn = await page.$('#update-value-btn')
      await updateValueBtn.tap()

      expect(await modelValueText.text()).toBe('modelValue in Foo: str1')
      expect(await modelValueInput.property('value')).toBe('str1')

      expect(await msgText.text()).toBe('msg in Foo: msg2')
      expect(await msgInput.property('value')).toBe('msg2')
    })
  } else {
    it('other platform', () => {
      expect(1).toBe(1)
    })
  }
})