unicloud-database.test.js 1.4 KB
Newer Older
雪洛's avatar
雪洛 已提交
1 2 3 4 5 6 7
const PAGE_PATH = '/pages/API/unicloud-database/unicloud-database'

describe('unicloud-database', () => {
  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 17 18 19
  })
  it('databaseBasic', async () => {
    await page.callMethod('dbRemove')
    await page.callMethod('dbAdd')
    await page.callMethod('dbBatchAdd')
    await page.callMethod('dbGet')
    await page.callMethod('dbGetWithCommand')
    await page.callMethod('dbUpdate')
    await page.callMethod('dbRemove')
20
    await page.callMethod('dbMultiSend')
21

雪洛's avatar
雪洛 已提交
22 23 24 25 26 27 28 29
    const {
      addId,
      batchAddIds,
      batchAddinserted,
      updateUpdated,
      getData,
      getWithCommandData,
      removeDeleted,
30
      multiSendSuccessCount,
雪洛's avatar
雪洛 已提交
31
    } = await page.data()
32

雪洛's avatar
雪洛 已提交
33
    expect(addId !== '').toBe(true)
雪洛's avatar
雪洛 已提交
34 35 36
    expect(batchAddIds.length).toBe(2)
    expect(batchAddinserted).toBe(2)
    expect(getData.length).toBe(2)
雪洛's avatar
雪洛 已提交
37
    expect(getWithCommandData.length).toBe(1)
雪洛's avatar
雪洛 已提交
38 39
    expect(updateUpdated).toBe(3)
    expect(removeDeleted).toBe(3)
40
    expect(multiSendSuccessCount).toBe(2)
41

雪洛's avatar
雪洛 已提交
42
  })
43

雪洛's avatar
雪洛 已提交
44 45 46
  it('databaseLookup', async () => {
    await page.callMethod('dbLookupInit')
    await page.callMethod('dbLookup')
47

雪洛's avatar
雪洛 已提交
48 49 50 51 52 53 54
    const {
      lookupData
    } = await page.data()
    expect(lookupData.length).toBe(2)
    expect(lookupData[0]['foreign_id'].length).toBe(1)
    expect(lookupData[1]['foreign_id'].length).toBe(1)
  })
55
});