parent
01c8cce238
commit
c5866443c0
@ -1,13 +1,23 @@
|
|||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import app, {server} from '../src/server';
|
import app, { startServer } from '../src/server';
|
||||||
|
import { Server, IncomingMessage, ServerResponse } from 'http';
|
||||||
|
|
||||||
describe('GET /api/endpoint', () => {
|
describe('GET /api/endpoint', () => {
|
||||||
it('should return a 200 status code', async () => {
|
let server: Server<typeof IncomingMessage, typeof ServerResponse>;
|
||||||
const response = await request(app).get('/');
|
|
||||||
expect(response.status).toBe(200);
|
beforeAll(() => {
|
||||||
});
|
server = startServer();
|
||||||
|
});
|
||||||
|
|
||||||
// Ecrire d'autres tests ici
|
afterAll((done) => {
|
||||||
|
server.close(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a 200 status code', async () => {
|
||||||
|
const response = await request(app).get('/');
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ecrire d'autres tests ici
|
||||||
|
|
||||||
server.close()
|
|
||||||
});
|
});
|
@ -0,0 +1,36 @@
|
|||||||
|
import request from 'supertest';
|
||||||
|
import app, { startServer } from '../src/server';
|
||||||
|
import { Server, IncomingMessage, ServerResponse } from 'http';
|
||||||
|
|
||||||
|
|
||||||
|
describe('GET /ingredients', () => {
|
||||||
|
let server: Server<typeof IncomingMessage, typeof ServerResponse>;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
server = startServer();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll((done) => {
|
||||||
|
server.close(done);
|
||||||
|
});
|
||||||
|
it('should return a 200 status code', async () => {
|
||||||
|
const response = await request(app).get('/ingredients/');
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a 200 status code', async () => {
|
||||||
|
const response = await request(app).get('/ingredients/1');
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a 400 status code', async () => {
|
||||||
|
const response = await request(app).get('/ingredients/l');
|
||||||
|
expect(response.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a 404 status code', async () => {
|
||||||
|
const response = await request(app).get('/ingredients/8024');
|
||||||
|
expect(response.status).toBe(404);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in new issue