unicloud-import-object.test.js 898 字节
Newer Older
雪洛's avatar
雪洛 已提交
1 2 3 4 5 6 7
const PAGE_PATH = '/pages/API/unicloud-import-object/unicloud-import-object'

describe('unicloud-import-object', () => {
  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(500)
8 9 10
    await page.setData({
      isUniTest: true
    })
雪洛's avatar
雪洛 已提交
11 12 13 14
  })
  it('importObject', async () => {
    await page.callMethod('addTodo')
    await page.callMethod('fail')
15
    await page.callMethod('failWithNumberErrCode')
雪洛's avatar
雪洛 已提交
16
    await page.callMethod('success')
17

雪洛's avatar
雪洛 已提交
18 19 20 21 22 23
    const {
      todoTitle,
      todoContent,
      returnTodoTitle,
      returnTodoContent,
      failErrCode,
雪洛's avatar
雪洛 已提交
24
      failNumberErrCode,
雪洛's avatar
雪洛 已提交
25 26
      successErrCode,
    } = await page.data()
27

雪洛's avatar
雪洛 已提交
28 29 30
    expect(returnTodoTitle).toBe(todoTitle)
    expect(returnTodoContent).toBe(todoContent)
    expect(failErrCode).toBe('TEST_ERROR_CODE')
雪洛's avatar
雪洛 已提交
31
    expect(failNumberErrCode).toBe(-1)
雪洛's avatar
雪洛 已提交
32
    expect(successErrCode).toBe(0)
33

雪洛's avatar
雪洛 已提交
34
  })
35
});