mirror of
https://github.com/Floriansylvain/SnippetsManager.git
synced 2026-08-20 03:43:35 +02:00
Added PUT route on category
This commit is contained in:
@@ -12,6 +12,8 @@ const testUserCredentials = {
|
||||
password: "aaaaaaaaaa"
|
||||
}
|
||||
|
||||
let category_id: number
|
||||
|
||||
// Mettre a jour les routes Category en stockant les IDs sur GET pour reutiliser sur DELETE
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -133,17 +135,36 @@ describe('GET /v1/category', () => {
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Cookie', jwtCookie as string)
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.body).toHaveProperty('categories')
|
||||
})
|
||||
category_id = res.body.categories[0].id
|
||||
|
||||
it('returns status code 400 and error message', async () => {
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.body.categories[0].name).toEqual('VueJS Composition API')
|
||||
})
|
||||
})
|
||||
|
||||
describe('PUT /v1/category', () => {
|
||||
it('returns status code 200 and a success message', async () => {
|
||||
const res = await request(app)
|
||||
.post('/v1/category')
|
||||
.put('/v1/category')
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Cookie', jwtCookie as string)
|
||||
.send(JSON.stringify({
|
||||
pouet: 'VueJS Composition API'
|
||||
id: category_id,
|
||||
name: 'VueJS v3 Composition API'
|
||||
}))
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.body).toHaveProperty('message')
|
||||
})
|
||||
|
||||
it('returns status code 400 and an error message', async () => {
|
||||
const res = await request(app)
|
||||
.put('/v1/category')
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Cookie', jwtCookie as string)
|
||||
.send(JSON.stringify({
|
||||
id: 2,
|
||||
pouet: 'salut'
|
||||
}))
|
||||
|
||||
expect(res.status).toEqual(400)
|
||||
@@ -158,7 +179,7 @@ describe('DELETE /v1/category', () => {
|
||||
.set('Content-Type', 'application/json')
|
||||
.set('Cookie', jwtCookie as string)
|
||||
.send(JSON.stringify({
|
||||
name: 'VueJS Composition API'
|
||||
id: category_id
|
||||
}))
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
|
||||
Reference in New Issue
Block a user