You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.send({ _id, project, comments, userId, username, name })//_id, project, comments, userId, username, name
169
+
.expect(200)
170
+
.then((res)=>{
171
+
expect(res.body._id).not.toEqual(_id)
172
+
});
173
+
});
174
+
});
175
+
});
176
+
177
+
//test getMarketplaceProjects endpoint
178
+
describe('/getMarketplaceProjects',()=>{//most recent project should be the one from publishProject
179
+
180
+
describe('GET',()=>{
181
+
it('responds with status of 200 and json object equal to unpublished project',async()=>{
182
+
returnrequest(app)
183
+
.get('/getMarketplaceProjects')
184
+
.set('Content-Type','application/json')
185
+
.expect(200)
186
+
.then((res)=>{
187
+
expect(Array.isArray(res.body)).toBe(true);
188
+
expect(res.body[0]._id).toBeTruthy;
189
+
});
190
+
});
191
+
});
192
+
});
193
+
194
+
//test cloneProject endpoint
195
+
describe('/cloneProject/:docId',()=>{
196
+
describe('GET',()=>{
197
+
it('responds with status of 200 and json object equal to cloned project',async()=>{
198
+
199
+
constprojObj=awaitrequest(app)
200
+
.get('/getMarketplaceProjects')
201
+
.set('Content-Type','application/json')
202
+
203
+
returnrequest(app)
204
+
.get(`/cloneProject/${projObj.body[0]._id}`)
205
+
.set('Cookie',[`ssid=${user.userId}`])// Set the cookie
206
+
.query({username: user.username})
207
+
.expect(200)
208
+
.then((res)=>{
209
+
expect(res.body.forked).toBeTruthy;
210
+
expect(res.body.username).toBe(user.username);
211
+
});
212
+
});
213
+
it('responds with status of 500 and error',async()=>{
214
+
215
+
constprojObj=awaitrequest(app)
216
+
.get('/getMarketplaceProjects')
217
+
.set('Content-Type','application/json')
218
+
219
+
returnrequest(app)
220
+
.get(`/cloneProject/${projObj.body[0]._id}`)
221
+
.set('Cookie',[`ssid=${user.userId}`])// Set the cookie
222
+
.query({username: []})
223
+
.expect(500)
224
+
.then((res)=>{
225
+
expect(res.body.err).not.toBeNull()
226
+
});
227
+
});
228
+
});
229
+
});
230
+
231
+
//test unpublishProject endpoint
232
+
describe('/unpublishProject',()=>{
233
+
describe('PATCH',()=>{
234
+
it('responds with status of 200 and json object equal to unpublished project',async()=>{
235
+
constresponse: Response=awaitrequest(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
236
+
const_id: String=response.body[0]._id;
237
+
constuserId: String=user.userId;
238
+
returnrequest(app)
239
+
.patch('/unpublishProject')
240
+
.set('Content-Type','application/json')
241
+
.set('Cookie',[`ssid=${user.userId}`])
242
+
.send({ _id, userId })
243
+
.expect(200)
244
+
.then((res)=>{
245
+
expect(res.body._id).toBe(_id)
246
+
expect(res.body.published).toBe(false);
247
+
});
248
+
});
249
+
it('responds with status of 500 and error if userId and cookie ssid do not match',async()=>{
0 commit comments