Skip to content

Commit

Permalink
tests ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara Martini committed Nov 29, 2023
1 parent 2aa4a00 commit e8c23d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ app.get('/products/:id', (request, response) => {
if (product) {
response.json(product);
} else {
response.status(404);
response.sendStatus(404);
}
});

Expand Down
28 changes: 12 additions & 16 deletions packages/backend/test/hello.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ test('First test', async () => {
server.close();
});

// test('Test /products endpoint', async () => {
// const server = createServer(4400);
// await request(SERVER_URL)
// .get('/products')
// .expect(200)
// .expect(function (response) {
// expect(response.body.length).toEqual(6);
// const cards = response.body;
// expect(cards[0].id).toEqual(0);
// });
// server.close();
// });
test('Test /products endpoint', async () => {
const server = createServer(4400);
await request(SERVER_URL)
.get('/products')
.expect(200)
.expect(function (response) {
expect(response.body.length).toEqual(6);
const cards = response.body;
expect(cards[0].id).toEqual(0);
});
server.close();
});

test('Test getProductById', async () => {
const server = createServer(4400);
Expand All @@ -36,9 +36,5 @@ test('Test nonexistent product id', async () => {
const productId = 10;
const response = await request(SERVER_URL).get(`/products/${productId}`);
expect(response.status).toEqual(404);
expect(response.body).toEqual({
error: 'Produit non trouvé',
});

server.close();
});

0 comments on commit e8c23d1

Please sign in to comment.