shallow-reactive.test.js 1.2 KB
Newer Older
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
const PAGE_PATH = '/pages/composition-api/reactivity/shallow-reactive/shallow-reactive'

describe('shallowReactive', () => {
  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 stateCount = await page.$('#state-count')
      expect(await stateCount.text()).toBe('state.count: 0')

      const stateNestedCount = await page.$('#state-nested-count')
      expect(await stateNestedCount.text()).toBe('state.nested.count: 0')

      const incrementStateNestedCountBtn = await page.$('#increment-state-nested-count-btn')
      await incrementStateNestedCountBtn.tap()

      expect(await stateNestedCount.text()).toBe('state.nested.count: 0')

      const incrementStateCountBtn = await page.$('#increment-state-count-btn')
      await incrementStateCountBtn.tap()

      expect(await stateCount.text()).toBe('state.count: 1')
      expect(await stateNestedCount.text()).toBe('state.nested.count: 1')
    })
  } else {
    it('other platform', () => {
      expect(1).toBe(1)
    })
  }
})