11import { expect } from '@jest/globals' ;
22import * as request from 'supertest' ;
33import { BASE_URL } from '../../constants/constants' ;
4+ import { TOKEN } from '../../constants/constants' ;
45
56describe ( 'Exemplos de teste usando o Get list' , ( ) => {
67
78 it ( 'Deve encontrar o registro e retornar o código de status 200' , async ( ) => {
8- const response = await request ( BASE_URL ) . get ( 'api/v1/Authors' ) ;
9+ const response = await request ( BASE_URL ) . get ( 'api/v1/Authors' )
10+ // .set('Authorization', `Bearer ${TOKEN}`); Configura o TOKEN aqui
911
1012 expect ( response . status ) . toBe ( 200 ) ;
1113 expect ( response . body [ 0 ] ) . toEqual ( expect . objectContaining (
@@ -22,6 +24,7 @@ describe('Exemplos de teste usando o Get list', () => {
2224
2325 it ( 'Deve encontrar o registro pelo id e retornar o código de status 200' , async ( ) => {
2426 const response = await request ( BASE_URL ) . get ( 'api/v1/Authors/2' ) ;
27+ // .set('Authorization', `Bearer ${TOKEN}`);
2528
2629 expect ( response . status ) . toBe ( 200 ) ;
2730 expect ( response . body ) . toEqual (
@@ -36,6 +39,7 @@ describe('Exemplos de teste usando o Get list', () => {
3639
3740 it ( 'Deve tentar encontrar o registro pelo id, mas não encontrado e retornar o código de status 404' , async ( ) => {
3841 const response = await request ( BASE_URL ) . get ( 'api/v1/Authors/1000' ) ;
42+ // .set('Authorization', `Bearer ${TOKEN}`);
3943
4044 expect ( response . status ) . toBe ( 404 ) ;
4145 expect ( response . body ) . toEqual ( expect . objectContaining (
@@ -60,6 +64,7 @@ describe('Exemplos de teste usando o Get list', () => {
6064 } ;
6165
6266 const response = await request ( BASE_URL )
67+ // .set('Authorization', `Bearer ${TOKEN}`);
6368 . post ( '/api/v1/Authors' )
6469 . send ( novoAutor ) ;
6570
@@ -73,7 +78,6 @@ describe('Exemplos de teste usando o Get list', () => {
7378
7479 }
7580 ) ) ;
76-
7781 } ) ;
7882
7983 it ( 'Deve tentar criar um autor com dados inválidos e verificar a resposta e o código de status 400' , async ( ) => {
@@ -85,6 +89,7 @@ describe('Exemplos de teste usando o Get list', () => {
8589 } ;
8690
8791 const response = await request ( BASE_URL )
92+ // .set('Authorization', `Bearer ${TOKEN}`);
8893 . post ( '/api/v1/Authors' )
8994 . send ( invalidAuthor ) ;
9095
0 commit comments