Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('return new amend data', async () => {
mockingoose.User.toReturn(userMock, 'findOne')
mockingoose.Amend.toReturn(amendMock, 'findOne')
mockingoose.Amend.toReturn(new Array(amendMock), 'find')
mockingoose.Event.toReturn(new Array(eventMock), 'find')
mockingoose.Text.toReturn(textMock, 'findOne')
const res = await Amend.postAmend(
{
name: 'test',
description: 'test',
patch: 'test',
version: 1,
textID: '5c64389cae3ae3695c711e44'
},
'wrongId'
)
expect(res).toHaveProperty('data')
})
})
test('should return data related to the text', async () => {
mockingoose.Text.toReturn(new Array(textMock), 'find')
expect(await Text.getTexts()).toHaveProperty('data')
})
})
test('should return text already followed', async () => {
mockingoose.User.toReturn(
{ ...userMock, followedTexts: ['5c64389cae3ae3695c711e44'] },
'findOne'
)
mockingoose.Text.toReturn(null, 'findOne')
expect(
await Text.followText('5c64389cae3ae3695c711e44', 'uv65v76v6779b9')
).toMatchObject({
error: { code: 405, message: 'Vous participez déjà à ce texte' }
})
})
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')
})
})