Skip to content

Commit 6080057

Browse files
committed
Create tests for false codeOfConduct in hacker
1 parent 76ec217 commit 6080057

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

tests/hacker.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const storedAccount2 = util.account.Account2;
3636
const storedHacker2 = util.hacker.HackerB;
3737

3838
const newHacker1 = util.hacker.newHacker1;
39+
// badConductHacker1 is the same as newHacker1, even linking to the same account
40+
// the difference is that badConductHacker1 does not accept the code of conducts
41+
const badConductHacker1 = util.hacker.badCodeOfConductHacker1;
3942
const newHackerAccount1 = util.account.allAccounts[13];
4043

4144
const newHacker2 = util.hacker.newHacker2;
@@ -288,6 +291,30 @@ describe("POST create hacker", function () {
288291
});
289292
});
290293

294+
// should fail due to 'false' on code of conduct
295+
it("should FAIL if the new hacker does not accept code of conduct", function (done) {
296+
util.auth.login(agent, newHackerAccount1, (error) => {
297+
if (error) {
298+
agent.close();
299+
return done(error);
300+
}
301+
return agent
302+
.post(`/api/hacker/`)
303+
.type("application/json")
304+
.send(badConductHacker1)
305+
.end(function (err, res) {
306+
res.should.have.status(422);
307+
res.should.be.json;
308+
res.body.should.have.property("message");
309+
res.body.message.should.equal("Validation failed");
310+
res.body.should.have.property("data");
311+
res.body.data.should.have.property("codeOfConduct");
312+
res.body.data.codeOfConduct.msg.should.equal("Must be equal to true");
313+
done();
314+
});
315+
});
316+
});
317+
291318
// fail on unconfirmed account, using admin
292319
it("should FAIL to create a new hacker if the account hasn't been confirmed", function (done) {
293320
util.auth.login(agent, Admin1, (error) => {

tests/util/hacker.test.util.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ const invalidHacker1 = {
2727
"codeOfConduct": true,
2828
};
2929

30+
// duplicate of newHack1, but with false for code of conduct
31+
const badCodeOfConductHacker1 = {
32+
"accountId": Util.Account.generatedAccounts[6]._id,
33+
"school": "University of ASDF",
34+
"degree": "Masters",
35+
"gender": "Female",
36+
"needsBus": true,
37+
"application": {
38+
"portfolioURL": {
39+
//gcloud bucket link
40+
"resume": "www.gcloud.com/myResume100",
41+
"github": "www.github.com/Person1",
42+
"dropler": undefined,
43+
"personal": "www.person1.com",
44+
"linkedIn": "www.linkedin.com/in/Person1",
45+
"other": undefined
46+
},
47+
"jobInterest": "Full-time",
48+
"skills": ["CSS", "HTML", "JS"],
49+
},
50+
"ethnicity": ["Caucasian"],
51+
"major": "EE",
52+
"graduationYear": 2019,
53+
"codeOfConduct": false,
54+
};
55+
3056
const duplicateAccountLinkHacker1 = {
3157
"_id": mongoose.Types.ObjectId(),
3258
"accountId": Util.Account.Account1._id,
@@ -195,6 +221,7 @@ module.exports = {
195221
invalidHacker1: invalidHacker1,
196222
newHacker1: newHacker1,
197223
newHacker2: newHacker2,
224+
badCodeOfConductHacker1: badCodeOfConductHacker1,
198225
HackerA: HackerA,
199226
HackerB: HackerB,
200227
HackerC: HackerC,

0 commit comments

Comments
 (0)