1
+ const coursesModel = require ( "../src/models/coursesModel" )
2
+
3
+ describe ( "GET route" , ( ) => {
4
+ const course = new coursesModel ( {
5
+ courseTitle : "teste back-end" ,
6
+ affirmativePolicies : [ "mulheres trans" ] ,
7
+ available : true ,
8
+ startDate : "22-06-2022" ,
9
+ finishDate : "22-09-2022" ,
10
+ category : [ "tecnologia" ] ,
11
+ description : "curso voltado a mulheres" ,
12
+ institutionID : "62c88976289c610293bc2cd1"
13
+ } ) ;
14
+ it ( "Deve chamar o schema e retornar o nome correto do curso" , ( ) => {
15
+ expect ( course . courseTitle ) . toBe ( "teste back-end" ) ;
16
+ } ) ;
17
+ it ( "Deve chamar o schema e retornar a politica afirmativa correta" , ( ) => {
18
+ expect ( course . affirmativePolicies ) . toStrictEqual ( [ "mulheres trans" ] ) ;
19
+ } ) ;
20
+ it ( "Deve chamar o schema e retornar se esta disponivel" , ( ) => {
21
+ expect ( course . available ) . toBe ( true ) ;
22
+ } ) ;
23
+ it ( "Deve chamar o schema e retornar a data inicial" , ( ) => {
24
+ expect ( course . startDate ) . toBe ( "22-06-2022" ) ;
25
+ } ) ;
26
+ it ( "Deve chamar o schema e retornar a data final" , ( ) => {
27
+ expect ( course . finishDate ) . toBe ( "22-09-2022" ) ;
28
+ } ) ;
29
+ it ( "Deve chamar o schema e retornar a categoria correta" , ( ) => {
30
+ expect ( course . category ) . toStrictEqual ( [ "tecnologia" ] ) ; ;
31
+ } ) ;
32
+ it ( "Deve chamar o schema e retornar a descrição correta" , ( ) => {
33
+ expect ( course . description ) . toBe ( "curso voltado a mulheres" ) ;
34
+ } ) ;
35
+ it ( "Deve chamar o schema e retornar o id da instituição correto" , ( ) => {
36
+ expect ( JSON . stringify ( course . institutionID ) . substring ( 1 , ( JSON . stringify ( course . institutionID ) ) . length - 1 ) ) . toBe ( "62c88976289c610293bc2cd1" ) ; ;
37
+ } ) ;
38
+ } ) ;
39
+
40
+ describe ( "CREATE route test" , ( ) => {
41
+ const course = new coursesModel ( {
42
+ courseTitle : "teste back-end" ,
43
+ affirmativePolicies : [ "mulheres trans" ] ,
44
+ available : true ,
45
+ startDate : "22-06-2022" ,
46
+ finishDate : "22-09-2022" ,
47
+ category : [ "tecnologia" ] ,
48
+ description : "curso voltado a mulheres" ,
49
+ institutionID : "62c88976289c610293bc2cd1"
50
+ } ) ;
51
+ it ( "Deve salvar no banco de dados o novo curso" , ( ) => {
52
+ course . save ( ) . then ( ( dados ) => {
53
+ expect ( dados . title ) . toBe ( "teste back-end" ) ;
54
+ } ) ;
55
+
56
+ } ) ;
57
+ } )
58
+
59
+
60
+ describe ( "UPDATE route test" , ( ) => {
61
+ it ( "Deve editar o titulo do curso" , ( ) => {
62
+ const course = new coursesModel ( {
63
+ courseTitle : "teste back-end" ,
64
+ affirmativePolicies : [ "mulheres trans" ] ,
65
+ available : true ,
66
+ startDate : "22-06-2022" ,
67
+ finishDate : "22-09-2022" ,
68
+ category : [ "tecnologia" ] ,
69
+ description : "curso voltado a mulheres" ,
70
+ institutionID : "62c88976289c610293bc2cd1"
71
+ } ) ;
72
+ course . title = "novo curso teste"
73
+ course . save ( ) . then ( ( dados ) => {
74
+ expect ( dados . title ) . toBe ( "novo curso teste" ) ;
75
+ } ) ;
76
+
77
+ } ) ;
78
+ } )
79
+
80
+ describe ( "DELETE route test" , ( ) => {
81
+ it ( "Deve excluir o curso" , ( ) => {
82
+ const course = new coursesModel ( {
83
+ courseTitle : "teste back-end" ,
84
+ affirmativePolicies : [ "mulheres trans" ] ,
85
+ available : true ,
86
+ startDate : "22-06-2022" ,
87
+ finishDate : "22-09-2022" ,
88
+ category : [ "tecnologia" ] ,
89
+ description : "curso voltado a mulheres" ,
90
+ institutionID : "62c88976289c610293bc2cd1"
91
+ } ) ;
92
+ course . save ( ) . then ( ( dados ) => {
93
+ course . delete ( ) . then ( ( novosdados ) => {
94
+ expect ( dados . title ) . toBe ( null ) ;
95
+ } )
96
+ } ) ;
97
+
98
+ } ) ;
99
+ } )
0 commit comments