-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(produtos): criar rota de busca de produto por ID
closes #211
- Loading branch information
1 parent
8f2632d
commit 938da13
Showing
11 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const chai = require('chai') | ||
|
||
const rotaProdutos = '/produtos' | ||
const utils = require('../utils') | ||
|
||
describe(`${rotaProdutos}/:id GET`, () => { | ||
it('Busca um produto específico', async () => { | ||
const { email, password } = await utils.cadastrarUsuario({ administrador: 'true' }) | ||
const { authorization } = await utils.login(email, password) | ||
const produto = await utils.cadastrarProduto({ authorization }) | ||
|
||
const { body } = await request.get(`${rotaProdutos}/${produto._id}`).expect(200) | ||
|
||
chai.assert.deepEqual(body, produto) | ||
}) | ||
|
||
it('Nenhum produto encontrado', async () => { | ||
const { body } = await request.get(`${rotaProdutos}/123`).expect(400) | ||
chai.assert.deepEqual(body, { | ||
message: 'Produto não encontrado' | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters