@@ -29,33 +29,36 @@ afterAll(async () => {
29
29
await mongoose . connection . close ( ) ;
30
30
} ) ;
31
31
32
+
33
+
32
34
describe ( 'Server endpoint tests' , ( ) => {
33
35
it ( 'should pass this test request' , async ( ) => {
34
36
const response = await request ( app ) . get ( '/test' ) ;
35
37
expect ( response . status ) . toBe ( 200 ) ;
36
38
expect ( response . text ) . toBe ( 'test request is working' ) ;
37
39
} ) ;
38
-
39
- // test saveProject endpoint
40
- describe ( '/login' , ( ) => {
41
- describe ( '/POST' , ( ) => {
42
- it ( 'responds with a status of 200 and json object equal to project sent' , async ( ) => {
43
- return request ( app )
44
- . post ( '/login' )
45
- . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
46
- . set ( 'Accept' , 'application/json' )
47
- . send ( projectToSave )
48
- . expect ( 200 )
49
- . expect ( 'Content-Type' , / a p p l i c a t i o n \/ j s o n / )
50
- . then ( ( res ) => expect ( res . body . name ) . toBe ( projectToSave . name ) ) ;
51
- } ) ;
52
- // });
53
- } ) ;
54
- } ) ;
40
+
41
+
42
+ // // test saveProject endpoint
43
+ // describe('/login', () => {
44
+ // describe('/POST', () => {
45
+ // it('responds with a status of 200 and json object equal to project sent', async () => {
46
+ // return request(app)
47
+ // .post('/login')
48
+ // .set('Cookie', [`ssid=${user.userId}`])
49
+ // .set('Accept', 'application/json')
50
+ // .send(projectToSave)
51
+ // .expect(200)
52
+ // .expect('Content-Type', /application\/json/)
53
+ // .then((res) => expect(res.body.name).toBe(projectToSave.name));
54
+ // });
55
+ // // });
56
+ // });
57
+ // });
55
58
56
59
// test saveProject endpoint
57
60
describe ( '/saveProject' , ( ) => {
58
- describe ( '/ POST' , ( ) => {
61
+ describe ( 'POST' , ( ) => {
59
62
it ( 'responds with a status of 200 and json object equal to project sent' , async ( ) => {
60
63
return request ( app )
61
64
. post ( '/saveProject' )
@@ -70,12 +73,13 @@ describe('Server endpoint tests', () => {
70
73
} ) ;
71
74
} ) ;
72
75
// test getProjects endpoint
73
- xdescribe ( '/getProjects' , ( ) => {
76
+ describe ( '/getProjects' , ( ) => {
74
77
describe ( 'POST' , ( ) => {
75
78
it ( 'responds with status of 200 and json object equal to an array of user projects' , ( ) => {
76
79
return request ( app )
77
80
. post ( '/getProjects' )
78
81
. set ( 'Accept' , 'application/json' )
82
+ . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
79
83
. send ( { userId : projectToSave . userId } )
80
84
. expect ( 200 )
81
85
. expect ( 'Content-Type' , / j s o n / )
@@ -87,14 +91,15 @@ describe('Server endpoint tests', () => {
87
91
} ) ;
88
92
} ) ;
89
93
// test deleteProject endpoint
90
- xdescribe ( '/deleteProject' , ( ) => {
94
+ describe ( '/deleteProject' , ( ) => {
91
95
describe ( 'DELETE' , ( ) => {
92
96
it ( 'responds with status of 200 and json object equal to deleted project' , async ( ) => {
93
- const response : Response = await request ( app ) . post ( '/getProjects' ) . set ( 'Accept' , 'application/json' ) . send ( { userId : projectToSave . userId } ) ;
97
+ const response : Response = await request ( app ) . post ( '/getProjects' ) . set ( 'Accept' , 'application/json' ) . set ( 'Cookie' , [ `ssid= ${ user . userId } ` ] ) . send ( { userId : projectToSave . userId } ) ;
94
98
const _id : String = response . body [ 0 ] . _id ;
95
99
const userId : String = user . userId ;
96
100
return request ( app )
97
101
. delete ( '/deleteProject' )
102
+ . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
98
103
. set ( 'Content-Type' , 'application/json' )
99
104
. send ( { _id, userId } )
100
105
. expect ( 200 )
@@ -104,12 +109,13 @@ describe('Server endpoint tests', () => {
104
109
} ) ;
105
110
106
111
//test publishProject endpoint
107
- xdescribe ( '/publishProject' , ( ) => {
112
+ describe ( '/publishProject' , ( ) => {
108
113
describe ( 'POST' , ( ) => {
109
114
it ( 'responds with status of 200 and json object equal to published project' , async ( ) => {
110
115
111
116
const projObj = await request ( app )
112
117
. post ( '/saveProject' )
118
+ . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
113
119
. set ( 'Accept' , 'application/json' )
114
120
. send ( projectToSave )
115
121
@@ -122,6 +128,7 @@ describe('Server endpoint tests', () => {
122
128
return request ( app )
123
129
. post ( '/publishProject' )
124
130
. set ( 'Content-Type' , 'application/json' )
131
+ . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
125
132
. send ( { _id, project, comments, userId, username, name } ) //_id, project, comments, userId, username, name
126
133
. expect ( 200 )
127
134
. then ( ( res ) => {
@@ -133,7 +140,7 @@ describe('Server endpoint tests', () => {
133
140
} ) ;
134
141
135
142
//test getMarketplaceProjects endpoint
136
- xdescribe ( '/getMarketplaceProjects' , ( ) => { //most recent project should be the one from publishProject
143
+ describe ( '/getMarketplaceProjects' , ( ) => { //most recent project should be the one from publishProject
137
144
describe ( 'GET' , ( ) => {
138
145
it ( 'responds with status of 200 and json object equal to unpublished project' , async ( ) => {
139
146
return request ( app )
@@ -150,7 +157,7 @@ describe('Server endpoint tests', () => {
150
157
} ) ;
151
158
152
159
//test cloneProject endpoint
153
- xdescribe ( '/cloneProject/:docId' , ( ) => {
160
+ describe ( '/cloneProject/:docId' , ( ) => {
154
161
describe ( 'GET' , ( ) => {
155
162
it ( 'responds with status of 200 and json object equal to cloned project' , async ( ) => {
156
163
@@ -178,15 +185,16 @@ describe('Server endpoint tests', () => {
178
185
} ) ;
179
186
180
187
//test unpublishProject endpoint
181
- xdescribe ( '/unpublishProject' , ( ) => {
188
+ describe ( '/unpublishProject' , ( ) => {
182
189
describe ( 'PATCH' , ( ) => {
183
190
it ( 'responds with status of 200 and json object equal to unpublished project' , async ( ) => {
184
- const response : Response = await request ( app ) . post ( '/getProjects' ) . set ( 'Accept' , 'application/json' ) . send ( { userId : projectToSave . userId } ) ; //most recent project should be the one from publishProject
191
+ const response : Response = await request ( app ) . post ( '/getProjects' ) . set ( 'Accept' , 'application/json' ) . set ( 'Cookie' , [ `ssid= ${ user . userId } ` ] ) . send ( { userId : projectToSave . userId } ) ; //most recent project should be the one from publishProject
185
192
const _id : String = response . body [ 0 ] . _id ;
186
193
const userId : String = user . userId ;
187
194
return request ( app )
188
195
. patch ( '/unpublishProject' )
189
196
. set ( 'Content-Type' , 'application/json' )
197
+ . set ( 'Cookie' , [ `ssid=${ user . userId } ` ] )
190
198
. send ( { _id, userId } ) //_id, project, comments, userId, username, name
191
199
. expect ( 200 )
192
200
. then ( ( res ) => {
0 commit comments