@@ -5,23 +5,26 @@ import {
55 dadoEsperadoGetById ,
66 getByIdNaoEncontrado ,
77 dadoEsperadoGetList ,
8- tentaCriarUmAutorComDadosInvalidos
8+ tentaCriarUmAutorComDadosInvalidos ,
9+ atualizaAutor
910} from '../data/author-data' ;
1011import { EntityService } from '../entity/entities' ;
1112import { authorsRoute } from '../routes/author-route' ;
1213
1314
14- const getList = authorsRoute . getListAuthors
15- const getById = authorsRoute . getAuthorsById
16- const create = authorsRoute . criaAutors
15+ const getListRoute = authorsRoute . getListAuthors ;
16+ const getByIdRoute = authorsRoute . getAuthorsById ;
17+ const createRoute = authorsRoute . criaAutors ;
18+ const updateRoute = authorsRoute . updateAuthors ;
19+ const deleteRoute = authorsRoute . deleteAuthors ;
1720
1821const entity = new EntityService ( ) ;
1922
2023describe ( 'Exemplos de teste usando o Get list' , ( ) => {
2124
2225 it ( 'Deve encontrar o registro e retornar o código de status 200' , async ( ) => {
2326 await entity . getList (
24- getList , // Rota para listar autores
27+ getListRoute , // Rota para listar autores
2528 200 , // Código de status esperado
2629 dadoEsperadoGetList // Dados esperados na resposta
2730 )
@@ -33,7 +36,7 @@ describe('Exemplos de teste usando o Get by id', () => {
3336
3437 it ( 'Deve encontrar o registro pelo id e retornar o código de status 200' , async ( ) => {
3538 await entity . getById (
36- getById ,
39+ getByIdRoute ,
3740 2 , // ID do autor a ser buscado
3841 200 ,
3942 dadoEsperadoGetById // Dados esperados na resposta
@@ -42,7 +45,7 @@ describe('Exemplos de teste usando o Get by id', () => {
4245
4346 it ( 'Deve tentar encontrar o registro pelo id, mas não encontrado e retornar o código de status 404' , async ( ) => {
4447 await entity . getById (
45- getById ,
48+ getByIdRoute ,
4649 1000 ,
4750 404 ,
4851 getByIdNaoEncontrado
@@ -54,7 +57,7 @@ describe('Exemplos de teste usando o Create', () => {
5457
5558 it ( 'Deve criar um autor e verificar os dados da resposta e o código de status 200' , async ( ) => {
5659 await entity . create (
57- create , // Rota para criar autor
60+ createRoute , // Rota para criar autor
5861 criaAutor , // Dados do autor a ser criado
5962 200 ,
6063 criaAutor
@@ -63,10 +66,36 @@ describe('Exemplos de teste usando o Create', () => {
6366
6467 it ( 'Deve tentar criar um autor com dados inválidos e verificar a resposta e o código de status 400' , async ( ) => {
6568 await entity . create (
66- create , // Rota para criar autor
69+ createRoute , // Rota para criar autor
6770 tentaCriarUmAutorComDadosInvalidos , // Dados do autor a ser criado
6871 400 , // Código de status esperado
6972 validaRetornoAutorInvalido
7073 )
7174 } )
75+
76+ } ) ;
77+
78+ describe ( 'Exemplos de teste usando o Update' , ( ) => {
79+
80+ it ( 'Deve criar um autor e verificar os dados da resposta e o código de status 200' , async ( ) => {
81+ await entity . update (
82+ updateRoute , // Rota para atualizar autor
83+ 1 , // ID do autor a ser atualizado
84+ atualizaAutor , // Dados do autor a ser atualizado
85+ 200 ,
86+ atualizaAutor // Dados esperados na resposta
87+ )
88+ } )
89+ } ) ;
90+
91+
92+ describe ( 'Exemplos de teste usando o delete' , ( ) => {
93+
94+ it ( 'Deve deletar o registro pelo id e retornar o código de status 200' , async ( ) => {
95+ await entity . delete (
96+ deleteRoute ,
97+ 1 , // ID do autor a ser deletado
98+ 200
99+ )
100+ } )
72101} ) ;
0 commit comments