Skip to content

Commit 1c03203

Browse files
author
fo057145
committed
remove prefix 'Bearer ' do token e ajusta importação nos testes
1 parent 2d321bc commit 1c03203

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

constants/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const BASE_URL = 'https://fakerestapi.azurewebsites.net/'
2-
export const TOKEN = 'Bearer YOUR_TOKEN_HERE'
2+
export const TOKEN = 'YOUR_TOKEN_HERE'

integration/tests/exemplo-uso-padrao.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { expect } from '@jest/globals';
22
import * as request from 'supertest';
33
import { BASE_URL } from '../../constants/constants';
4+
import { TOKEN } from '../../constants/constants';
45

56
describe('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

Comments
 (0)