Commit 3389514d authored by Arthur Sudbrack Ibarra's avatar Arthur Sudbrack Ibarra 😁
Browse files

Finalizado os testes de endpoint para obter uma receita por id

parent ae06a330
Pipeline #1126 passed with stage
in 1 minute and 4 seconds
Showing with 16 additions and 6 deletions
+16 -6
import supertest from 'supertest';
import indexTags from '../../controllers/tagController';
import db from '../../database/connection';
import Recipe from '../../models/recipe';
import app from '../../server';
......@@ -60,8 +59,6 @@ describe('Getting recipes - Endpoint', () => {
});
});
it('Like number property should be zero or greather', async () => {
const response = await request.get('/recipes');
......@@ -113,7 +110,7 @@ describe('Getting recipes - Endpoint', () => {
expect(recipe).toHaveProperty('steps');
});
});
it('recipe_id should have to be the same of the passed id', async () => {
it('recipe_id should be the same as the passed id', async () => {
const response = await request.get('/recipes/1');
const recipe: Recipe = response.body.data;
......@@ -123,6 +120,21 @@ describe('Getting recipes - Endpoint', () => {
expect(recipe.recipe_id).toBe(1);
});
it('recipe should have the property recipe_id', async () => {
const response = await request.get('/recipes/1');
const recipe: Recipe = response.body.data;
expect(response.status).toBe(200);
expect(response.body).not.toBe(null);
expect(recipe).toHaveProperty('recipe_id');
});
it('should not return a recipe with an id that doesnt exists', async () => {
const response = await request.get('/recipes/9999');
expect(response.status).toBe(404);
expect(response.body).toBe(null);
});
});
describe('Creating recipes - Endpoint', () => {
......@@ -217,8 +229,6 @@ describe('Creating recipes - Endpoint', () => {
});
});
afterAll(async () => {
await db.migrate.rollback();
await db.destroy();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment