Skip to content

Commit f2befb5

Browse files
committed
got testing up to 55.53%
1 parent bf4908e commit f2befb5

File tree

5 files changed

+250
-150
lines changed

5 files changed

+250
-150
lines changed

__tests__/server.test.tsx

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,36 @@ afterAll(async () => {
2929
await mongoose.connection.close();
3030
});
3131

32+
33+
3234
describe('Server endpoint tests', () => {
3335
it('should pass this test request', async () => {
3436
const response = await request(app).get('/test');
3537
expect(response.status).toBe(200);
3638
expect(response.text).toBe('test request is working');
3739
});
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', /application\/json/)
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+
// });
5558

5659
// test saveProject endpoint
5760
describe('/saveProject', () => {
58-
describe('/POST', () => {
61+
describe('POST', () => {
5962
it('responds with a status of 200 and json object equal to project sent', async () => {
6063
return request(app)
6164
.post('/saveProject')
@@ -70,12 +73,13 @@ describe('Server endpoint tests', () => {
7073
});
7174
});
7275
// test getProjects endpoint
73-
xdescribe('/getProjects', () => {
76+
describe('/getProjects', () => {
7477
describe('POST', () => {
7578
it('responds with status of 200 and json object equal to an array of user projects', () => {
7679
return request(app)
7780
.post('/getProjects')
7881
.set('Accept', 'application/json')
82+
.set('Cookie', [`ssid=${user.userId}`])
7983
.send({ userId: projectToSave.userId })
8084
.expect(200)
8185
.expect('Content-Type', /json/)
@@ -87,14 +91,15 @@ describe('Server endpoint tests', () => {
8791
});
8892
});
8993
// test deleteProject endpoint
90-
xdescribe('/deleteProject', () => {
94+
describe('/deleteProject', () => {
9195
describe('DELETE', () => {
9296
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 });
9498
const _id: String = response.body[0]._id;
9599
const userId: String = user.userId;
96100
return request(app)
97101
.delete('/deleteProject')
102+
.set('Cookie', [`ssid=${user.userId}`])
98103
.set('Content-Type', 'application/json')
99104
.send({ _id, userId })
100105
.expect(200)
@@ -104,12 +109,13 @@ describe('Server endpoint tests', () => {
104109
});
105110

106111
//test publishProject endpoint
107-
xdescribe('/publishProject', () => {
112+
describe('/publishProject', () => {
108113
describe('POST', () => {
109114
it('responds with status of 200 and json object equal to published project', async () => {
110115

111116
const projObj = await request(app)
112117
.post('/saveProject')
118+
.set('Cookie', [`ssid=${user.userId}`])
113119
.set('Accept', 'application/json')
114120
.send(projectToSave)
115121

@@ -122,6 +128,7 @@ describe('Server endpoint tests', () => {
122128
return request(app)
123129
.post('/publishProject')
124130
.set('Content-Type', 'application/json')
131+
.set('Cookie', [`ssid=${user.userId}`])
125132
.send({ _id, project, comments, userId, username, name })//_id, project, comments, userId, username, name
126133
.expect(200)
127134
.then((res) => {
@@ -133,7 +140,7 @@ describe('Server endpoint tests', () => {
133140
});
134141

135142
//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
137144
describe('GET', () => {
138145
it('responds with status of 200 and json object equal to unpublished project', async () => {
139146
return request(app)
@@ -150,7 +157,7 @@ describe('Server endpoint tests', () => {
150157
});
151158

152159
//test cloneProject endpoint
153-
xdescribe('/cloneProject/:docId', () => {
160+
describe('/cloneProject/:docId', () => {
154161
describe('GET', () => {
155162
it('responds with status of 200 and json object equal to cloned project', async () => {
156163

@@ -178,15 +185,16 @@ describe('Server endpoint tests', () => {
178185
});
179186

180187
//test unpublishProject endpoint
181-
xdescribe('/unpublishProject', () => {
188+
describe('/unpublishProject', () => {
182189
describe('PATCH', () => {
183190
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
185192
const _id: String = response.body[0]._id;
186193
const userId: String = user.userId;
187194
return request(app)
188195
.patch('/unpublishProject')
189196
.set('Content-Type', 'application/json')
197+
.set('Cookie', [`ssid=${user.userId}`])
190198
.send({ _id, userId })//_id, project, comments, userId, username, name
191199
.expect(200)
192200
.then((res) => {

0 commit comments

Comments
 (0)