How to use the mockingoose.Amend function in mockingoose

To help you get started, we’ve selected a few mockingoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jimmyleray / Emendare / old-server / src / models / amend / Amend.spec.ts View on Github external
test('Return amend data', async () => {
    mockingoose.User.toReturn(
      {
        ...userMock,
        followedTexts: ['5c64389cae3ae3695c711e44']
      },
      'findOne'
    )
    mockingoose.Amend.toReturn({ ...amendMock, closed: false }, 'findOne')
    expect(
      await Amend.indVoteAmend('5c64389cae3ae3695c711e44', '29UH90D0H39')
    ).toHaveProperty('data')
  })
})
github jimmyleray / Emendare / old-server / src / models / amend / Amend.spec.ts View on Github external
test("Amend doesn't exist", async () => {
    mockingoose.Amend.toReturn(null, 'findOne')
    expect(await Amend.getAmend('wrongId')).toMatchObject({
      error: {
        code: 404,
        message: "Oups, cet amendement n'existe pas ou plus"
      }
    })
  })
github jimmyleray / Emendare / old-server / src / models / user / User.spec.ts View on Github external
test('should delete user without error', async () => {
    mockingoose.User.toReturn(userMock, 'findOne')
    mockingoose.Amend.toReturn(amendMock, 'findOne')
    mockingoose.Text.toReturn(new Array(textMock), 'findOne')
    const token = (await User.login('test@test.com', 'abcd', '')).data
    const res = await User.delete(token)
    expect(res).not.toHaveProperty('error')
  })
})

mockingoose

A Jest package for mocking mongoose models

Unlicense
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis