unicloud-import-object.test.js 1.1 KB
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
  })
  it('importObject', async () => {
    await page.callMethod('addTodo')
14
    await page.callMethod('addTodoWithGeneric')
雪洛's avatar
雪洛 已提交
15
    await page.callMethod('fail')
16
    await page.callMethod('failWithNumberErrCode')
雪洛's avatar
雪洛 已提交
17
    await page.callMethod('success')
18

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

雪洛's avatar
雪洛 已提交
31 32
    expect(returnTodoTitle).toBe(todoTitle)
    expect(returnTodoContent).toBe(todoContent)
33 34
    expect(genericDemoReturnTodoTitle).toBe(todoTitle)
    expect(genericDemoReturnTodoContent).toBe(todoContent)
雪洛's avatar
雪洛 已提交
35
    expect(failErrCode).toBe('TEST_ERROR_CODE')
雪洛's avatar
雪洛 已提交
36
    expect(failNumberErrCode).toBe(-1)
雪洛's avatar
雪洛 已提交
37
    expect(successErrCode).toBe(0)
38

雪洛's avatar
雪洛 已提交
39
  })
40
});