fix: valider data.user/data.artistes avant déréférencement
This commit is contained in:
@@ -66,4 +66,26 @@ describe('parole.create', () => {
|
||||
|
||||
expect(paroleDocuments.create).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('refuse sans planter quand data.user est absent', async () => {
|
||||
const {strapi, userDocuments} = buildStrapi({dbUser, artiste})
|
||||
const controller = createController({strapi})
|
||||
const ctx = buildCtx(buildData({user: undefined}))
|
||||
|
||||
await controller.create(ctx)
|
||||
|
||||
expect(ctx.badRequest).toHaveBeenCalled()
|
||||
expect(userDocuments.findOne).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('refuse sans planter quand data.artistes est vide', async () => {
|
||||
const {strapi, artisteDocuments} = buildStrapi({dbUser, artiste})
|
||||
const controller = createController({strapi})
|
||||
const ctx = buildCtx(buildData({artistes: []}))
|
||||
|
||||
await controller.create(ctx)
|
||||
|
||||
expect(ctx.badRequest).toHaveBeenCalled()
|
||||
expect(artisteDocuments.findOne).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user