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

describe('unicloud-call-function', () => {
  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 15 16
  })

  it('callFunction', async () => {
    await page.callMethod('callFunction')
    const {
      callFunctionResult,
17
      callFunctionError,
雪洛's avatar
雪洛 已提交
18 19 20 21 22 23 24
    } = await page.data()
    console.error(callFunctionResult)
    console.error(callFunctionError)
    expect(callFunctionResult['showMessage']).toBe("Hello uniCloud function")
    expect(callFunctionResult['event']['num']).toBe(1)
    expect(callFunctionResult['event']['str']).toBe('ABC')
  })
25 26 27 28 29 30 31 32

  it('callFunctionWithGeneric', async () => {
    await page.callMethod('callFunctionWithGeneric')
    const {
      genericDemoShowMessage,
    } = await page.data()
    expect(genericDemoShowMessage).toBe("Hello uniCloud function")
  })
雪洛's avatar
雪洛 已提交
33
})