Skip to content

Commit 3b8532f

Browse files
committed
Make final changes
1 parent 16a962a commit 3b8532f

16 files changed

+153
-109
lines changed

tests/hacker.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ describe("PATCH update one hacker", function () {
634634
return done(error);
635635
}
636636
return agent
637-
.patch(`/api/hacker/confirmation/${noTeamHacker0._id}`)
637+
.patch(`/api/hacker/confirmation/${TeamHacker0._id}`)
638638
.type("application/json")
639639
.send({
640640
confirm: false

tests/role.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Constants = {
1818
Success: require("../constants/success.constant"),
1919
};
2020

21-
const Admin0 = util.account.staffAccounts[0];
21+
const Admin0 = util.account.staffAccounts.stored[0];
2222
const Hacker0 = util.account.hackerAccounts.stored.team[0];
2323

2424
describe("POST create role", function () {

tests/search.service.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const badQuery = [{
3838
value: "passowrd"
3939
}];
4040

41-
const Admin0 = util.account.staffAccounts[0];
41+
const Admin0 = util.account.staffAccounts.stored[0];
4242

4343
const noTeamHackerAccount0 = util.account.hackerAccounts.stored.noTeam[0];
4444

@@ -164,7 +164,7 @@ describe("Searching for hackers", function () {
164164
});
165165
});
166166
});
167-
it("Should throw an error because out of a fake model", function (done) {
167+
it("Should throw an error because of a fake model", function (done) {
168168
util.auth.login(agent, Admin0, (error) => {
169169
if (error) {
170170
agent.close();

tests/setup.spec.js

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const Util = {
1515
AccountConfirmation: require("./util/accountConfirmation.test.util"),
1616
ResetPassword: require("./util/resetPassword.test.util.js")
1717
};
18-
const Constants = {
19-
Role: require("../constants/role.constant"),
20-
};
2118
const logger = require("../services/logger.service");
2219

2320
//make sure that we are connected to the database
@@ -53,56 +50,17 @@ afterEach(function (done) {
5350
});
5451
});
5552
async function storeAll() {
56-
await Util.Account.storeAll(Util.Account.hackerAccounts.stored.team);
57-
await Util.Account.storeAll(Util.Account.hackerAccounts.stored.noTeam);
58-
await Util.Account.storeAll(Util.Account.volunteerAccounts.stored);
59-
await Util.Account.storeAll(Util.Account.staffAccounts.stored);
60-
await Util.Account.storeAll(Util.Account.sponsorT1Accounts.stored);
61-
await Util.Account.storeAll(Util.Account.sponsorT2Accounts.stored);
62-
await Util.Account.storeAll(Util.Account.sponsorT3Accounts.stored);
63-
await Util.Account.storeAll(Util.Account.sponsorT4Accounts.stored);
64-
await Util.Account.storeAll(Util.Account.sponsorT5Accounts.stored);
65-
await Util.Account.storeAll(Util.Account.unlinkedAccounts.stored);
66-
67-
await Util.Account.storeAll(Util.Account.hackerAccounts.new);
68-
await Util.Account.storeAll(Util.Account.volunteerAccounts.new);
69-
await Util.Account.storeAll(Util.Account.sponsorT1Accounts.new);
70-
await Util.Account.storeAll(Util.Account.sponsorT2Accounts.new);
71-
await Util.Account.storeAll(Util.Account.sponsorT3Accounts.new);
72-
await Util.Account.storeAll(Util.Account.sponsorT4Accounts.new);
73-
await Util.Account.storeAll(Util.Account.sponsorT5Accounts.new);
74-
75-
await Util.Account.storeAll(Util.Account.extraAccounts);
76-
77-
await Util.Hacker.storeAll(Util.Hacker.Hackers);
78-
await Util.Sponsor.storeAll(Util.Sponsor.Sponsors);
79-
await Util.Team.storeAll(Util.Team.Teams);
80-
await Util.Staff.storeAll(Util.Staff.Staffs);
81-
await Util.AccountConfirmation.storeAll(Util.AccountConfirmation.AccountConfirmationTokens);
82-
await Util.ResetPassword.storeAll(Util.ResetPassword.ResetPasswords);
83-
await Util.Bus.storeAll(Util.Bus.Busses);
84-
await Util.Volunteer.storeAll(Util.Volunteer.Volunteers);
85-
await Util.Role.storeAll(Constants.Role.allRolesArray);
86-
87-
await Util.RoleBinding.storeAll(Util.RoleBinding.TeamHackerRB);
88-
await Util.RoleBinding.storeAll(Util.RoleBinding.NoTeamHackerRB);
89-
await Util.RoleBinding.storeAll(Util.RoleBinding.VolunteerRB);
90-
await Util.RoleBinding.storeAll(Util.RoleBinding.StaffRB);
91-
await Util.RoleBinding.storeAll(Util.RoleBinding.SponsorT1RB);
92-
await Util.RoleBinding.storeAll(Util.RoleBinding.SponsorT2RB);
93-
await Util.RoleBinding.storeAll(Util.RoleBinding.SponsorT3RB);
94-
await Util.RoleBinding.storeAll(Util.RoleBinding.SponsorT4RB);
95-
await Util.RoleBinding.storeAll(Util.RoleBinding.SponsorT5RB);
96-
97-
await Util.RoleBinding.storeAll(Util.RoleBinding.newHackerRB);
98-
await Util.RoleBinding.storeAll(Util.RoleBinding.newVolunteerRB);
99-
await Util.RoleBinding.storeAll(Util.RoleBinding.newSponsorT1RB);
100-
await Util.RoleBinding.storeAll(Util.RoleBinding.newSponsorT2RB);
101-
await Util.RoleBinding.storeAll(Util.RoleBinding.newSponsorT3RB);
102-
await Util.RoleBinding.storeAll(Util.RoleBinding.newSponsorT4RB);
103-
await Util.RoleBinding.storeAll(Util.RoleBinding.newSponsorT5RB);
104-
105-
await Util.RoleBinding.storeAll(Util.RoleBinding.unconfirmedAccountRB);
53+
await Util.Account.storeAll();
54+
await Util.Hacker.storeAll();
55+
await Util.Sponsor.storeAll();
56+
await Util.Team.storeAll();
57+
await Util.Staff.storeAll();
58+
await Util.AccountConfirmation.storeAll();
59+
await Util.ResetPassword.storeAll();
60+
await Util.Bus.storeAll();
61+
await Util.Volunteer.storeAll();
62+
await Util.Role.storeAll();
63+
await Util.RoleBinding.storeAll();
10664
}
10765

10866
async function dropAll() {

tests/team.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Constants = {
2020

2121
const agent = chai.request.agent(server.app);
2222

23-
const Admin0 = util.account.staffAccounts[0];
23+
const Admin0 = util.account.staffAccounts.stored[0];
2424
const teamHackerAccount0 = util.account.hackerAccounts.stored.team[0];
2525
const noTeamHackerAccount0 = util.account.hackerAccounts.stored.noTeam[0];
2626
const sponsorT1Account0 = util.account.sponsorT1Accounts.stored[0];
@@ -77,14 +77,14 @@ describe("GET team", function () {
7777
res.body.data.should.have.property("team");
7878
res.body.data.team.name.should.equal("FullTeam");
7979
res.body.data.should.have.property("members");
80-
res.body.data.members[0].firstName.should.equal("abcd");
81-
res.body.data.members[0].lastName.should.equal("defg4");
82-
res.body.data.members[1].firstName.should.equal("abcd");
83-
res.body.data.members[1].lastName.should.equal("defg5");
84-
res.body.data.members[2].firstName.should.equal("abcd");
85-
res.body.data.members[2].lastName.should.equal("defg6");
86-
res.body.data.members[3].firstName.should.equal("abcd");
87-
res.body.data.members[3].lastName.should.equal("defg7");
80+
res.body.data.members[0].firstName.should.equal(util.account.hackerAccounts.stored.team[1].firstName);
81+
res.body.data.members[0].lastName.should.equal(util.account.hackerAccounts.stored.team[1].lastName);
82+
res.body.data.members[1].firstName.should.equal(util.account.hackerAccounts.stored.team[2].firstName);
83+
res.body.data.members[1].lastName.should.equal(util.account.hackerAccounts.stored.team[2].lastName);
84+
res.body.data.members[2].firstName.should.equal(util.account.hackerAccounts.stored.team[3].firstName);
85+
res.body.data.members[2].lastName.should.equal(util.account.hackerAccounts.stored.team[3].lastName);
86+
res.body.data.members[3].firstName.should.equal(util.account.hackerAccounts.stored.team[4].firstName);
87+
res.body.data.members[3].lastName.should.equal(util.account.hackerAccounts.stored.team[4].lastName);
8888

8989
done();
9090
});
@@ -368,7 +368,7 @@ describe("PATCH join team", function () {
368368
describe("PATCH change team info", function () {
369369
it("should FAIL to change a hacker's team information due to invalid authentication", function (done) {
370370
chai.request(server.app)
371-
.patch(`/api/team/${util.hacker.HackerF._id}`)
371+
.patch(`/api/team/${util.hacker.TeamHacker4._id}`)
372372
.type("application/json")
373373
.send({
374374
name: "BronzeTeamASDF",
@@ -391,7 +391,7 @@ describe("PATCH change team info", function () {
391391
return done(error);
392392
}
393393
return agent
394-
.patch(`/api/team/${util.hacker.HackerA._id}`)
394+
.patch(`/api/team/${util.hacker.TeamHacker0._id}`)
395395
.type("application/json")
396396
.send({
397397
name: "SuccessTeamASDF",
@@ -408,14 +408,14 @@ describe("PATCH change team info", function () {
408408
});
409409
});
410410

411-
it("should SUCCEED to change the hacker's team information (even though the hackers are different, the team is the same)", function (done) {
411+
it("should SUCCEED to change the hacker's team information", function (done) {
412412
util.auth.login(agent, util.account.hackerAccounts.stored.team[1], (error) => {
413413
if (error) {
414414
agent.close();
415415
return done(error);
416416
}
417417
return agent
418-
.patch(`/api/team/${util.hacker.HackerD._id}`)
418+
.patch(`/api/team/${util.hacker.TeamHacker1._id}`)
419419
.type("application/json")
420420
.send({
421421
name: "SuccessTeamASDF",
@@ -460,7 +460,7 @@ describe("PATCH change team info", function () {
460460
return done(error);
461461
}
462462
return agent
463-
.patch(`/api/team/${util.hacker.HackerD._id}`)
463+
.patch(`/api/team/${util.hacker.TeamHacker3._id}`)
464464
.type("application/json")
465465
.send({
466466
name: "SuccessTeamASDF",

tests/util/account.test.util.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ let sponsorT5Accounts = {
207207

208208
let unlinkedAccounts = {
209209
new: [createAccount({
210-
"accountType": Constants.HACKER
210+
"accountType": Constants.HACKER,
211+
"confirmed": false,
211212
})],
212213
invalid: [createAccount()],
213214
stored: [createAccount({
@@ -297,7 +298,7 @@ function encryptPassword(user) {
297298
return encryptedUser;
298299
}
299300

300-
function storeAll(attributes) {
301+
function store(attributes) {
301302
const acctDocs = [];
302303
const acctNames = [];
303304
for (var i = 0; i < attributes.length; i++) {
@@ -309,6 +310,29 @@ function storeAll(attributes) {
309310
return Account.collection.insertMany(acctDocs);
310311
}
311312

313+
async function storeAll() {
314+
await store(hackerAccounts.stored.team);
315+
await store(hackerAccounts.stored.noTeam);
316+
await store(volunteerAccounts.stored);
317+
await store(staffAccounts.stored);
318+
await store(sponsorT1Accounts.stored);
319+
await store(sponsorT2Accounts.stored);
320+
await store(sponsorT3Accounts.stored);
321+
await store(sponsorT4Accounts.stored);
322+
await store(sponsorT5Accounts.stored);
323+
await store(unlinkedAccounts.stored);
324+
325+
await store(hackerAccounts.new);
326+
await store(volunteerAccounts.new);
327+
await store(sponsorT1Accounts.new);
328+
await store(sponsorT2Accounts.new);
329+
await store(sponsorT3Accounts.new);
330+
await store(sponsorT4Accounts.new);
331+
await store(sponsorT5Accounts.new);
332+
333+
await store(extraAccounts);
334+
}
335+
312336
async function dropAll() {
313337
try {
314338
await Account.collection.drop();

tests/util/accountConfirmation.test.util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const AccountConfirmationTokens = [
5656
HackerConfirmation4
5757
];
5858

59-
function storeAll(attributes) {
59+
function store(attributes) {
6060
const accountConfirmationDocs = [];
6161
const accountConfirmationIds = [];
6262
for (var i = 0; i < attributes.length; i++) {
@@ -66,6 +66,10 @@ function storeAll(attributes) {
6666
return AccountConfirmationToken.collection.insertMany(accountConfirmationDocs);
6767
}
6868

69+
async function storeAll() {
70+
await store(AccountConfirmationTokens);
71+
}
72+
6973
async function dropAll() {
7074
try {
7175
await AccountConfirmationToken.collection.drop();

tests/util/bus.test.util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
dropAll: dropAll
2929
};
3030

31-
function storeAll(attributes) {
31+
function store(attributes) {
3232
const busDocs = [];
3333
const busZips = [];
3434
for (var i = 0; i < attributes.length; i++) {
@@ -39,6 +39,10 @@ function storeAll(attributes) {
3939
return Bus.collection.insertMany(busDocs);
4040
}
4141

42+
async function storeAll() {
43+
await store(Busses);
44+
}
45+
4246
async function dropAll() {
4347
try {
4448
await Bus.collection.drop();

tests/util/hacker.test.util.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ const unconfirmedAccountHacker0 = {
353353
"major": "EE",
354354
"graduationYear": 2019,
355355
"codeOfConduct": true,
356-
}
356+
};
357357

358358
const Hackers = [
359359
TeamHacker0,
@@ -392,7 +392,7 @@ module.exports = {
392392
dropAll: dropAll
393393
};
394394

395-
function storeAll(attributes) {
395+
function store(attributes) {
396396
const hackerDocs = [];
397397
const hackerIds = [];
398398
for (var i = 0; i < attributes.length; i++) {
@@ -403,6 +403,10 @@ function storeAll(attributes) {
403403
return Hacker.collection.insertMany(hackerDocs);
404404
}
405405

406+
async function storeAll() {
407+
await store(Hackers);
408+
}
409+
406410
async function dropAll() {
407411
try {
408412
await Hacker.collection.drop();

tests/util/resetPassword.test.util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ResetPasswords = [
2323
ResetPasswordToken1
2424
];
2525

26-
function storeAll(attributes) {
26+
function store(attributes) {
2727
const resetPasswordDocs = [];
2828
const resetPasswordIds = [];
2929
for (var i = 0; i < attributes.length; i++) {
@@ -33,6 +33,10 @@ function storeAll(attributes) {
3333
return ResetPassword.collection.insertMany(resetPasswordDocs);
3434
}
3535

36+
async function storeAll() {
37+
await store(ResetPasswords);
38+
}
39+
3640
async function dropAll() {
3741
try {
3842
await ResetPassword.collection.drop();

0 commit comments

Comments
 (0)