File tree 2 files changed +54
-0
lines changed
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ # language: pt
2
+ @importante
3
+ Funcionalidade : Gestionar Mensagem
4
+ @fast @rapido @mobile
5
+ Cenário : Cadastrar mensagem
6
+ Dado que eu tenha uma mensagem válida
7
+ Quando enviar a mensagem para cadastrar
8
+ Então a mensagem deve ser registrada com sucesso
9
+
10
+ @slow @lento @dificil @mobile
11
+ Cenário : Ao cadastrar mensagem sem usuário deve gerar um erro
12
+ Dado que eu tenha uma mensagem sem o campo usuário
13
+ Quando enviar a mensagem para cadastrar
14
+ Então a mensagem não é cadastrada
15
+ E deve apresentar erro indicando que o campo 'usuário' é obrigatório
16
+
Original file line number Diff line number Diff line change
1
+ import { Given , When , Then } from "@cucumber/cucumber" ;
2
+ import app from "../../../src/server" ;
3
+ import request from "supertest" ;
4
+ import assert from "assert" ;
5
+
6
+ let payload , response ;
7
+
8
+ Given ( "que eu tenha uma mensagem válida" , function ( ) {
9
+ payload = {
10
+ usuario : "usuario_01" ,
11
+ conteudo : "olá mundo" ,
12
+ } ;
13
+ } ) ;
14
+
15
+ Given ( "que eu tenha uma mensagem sem o campo usuário" , function ( ) {
16
+ payload = {
17
+ conteudo : "olá mundo" ,
18
+ } ;
19
+ } ) ;
20
+
21
+ When ( "enviar a mensagem para cadastrar" , async ( ) => {
22
+ response = await request ( app ) . post ( "/mensagens" ) . send ( payload ) ;
23
+ } ) ;
24
+
25
+ Then ( "a mensagem deve ser registrada com sucesso" , function ( ) {
26
+ assert . equal ( response . status , 201 ) ;
27
+ } ) ;
28
+
29
+ Then ( "a mensagem não é cadastrada" , function ( ) {
30
+ assert . equal ( response . status , 500 ) ;
31
+ } ) ;
32
+
33
+ Then (
34
+ "deve apresentar erro indicando que o campo 'usuário' é obrigatório" ,
35
+ function ( ) {
36
+ assert . ok ( response . body . error . includes ( "o campo 'usuario' é obrigatório" ) )
37
+ }
38
+ ) ;
You can’t perform that action at this time.
0 commit comments