@@ -23,33 +23,29 @@ const util = {
2323const StorageService = require ( "../services/storage.service" ) ;
2424
2525const Admin0 = util . account . staffAccounts . stored [ 0 ] ;
26- const teamHackerAccount0 = util . account . hackerAccounts . stored . team [ 0 ] ;
27- // linked with hackerB - fix later
28- const noTeamHackerAccount0 = util . account . hackerAccounts . stored . noTeam [ 0 ] ;
29- const volunteerAccount0 = util . account . volunteerAccounts . stored [ 0 ] ;
3026
31- // storedAccount1 and storedHacker1 are linked together, and have hacker priviledges
32- // newHackerDuplicateAccountLink1 is also linked with Account1
33- // storedHacker1 has status confirmed
34- const storedHacker1 = util . hacker . HackerA ;
35- const newHackerDuplicateAccountLink1 = util . hacker . duplicateAccountLinkHacker1 ;
27+ const volunteerAccount0 = util . account . volunteerAccounts . stored [ 0 ] ;
3628
37- const storedHacker2 = util . hacker . HackerB ;
29+ const newHackerAccount0 = util . account . hackerAccounts . new [ 0 ] ;
30+ const newHacker0 = util . hacker . newHacker0 ;
31+ const invalidHacker0 = util . hacker . invalidHacker0 ;
3832
3933const newHacker1 = util . hacker . newHacker1 ;
40- // badConductHacker1 is the same as newHacker1, even linking to the same account
41- // the difference is that badConductHacker1 does not accept the code of conducts
42- const badConductHacker1 = util . hacker . badCodeOfConductHacker1 ;
43- const newHackerAccount1 = util . account . allAccounts [ 13 ] ;
4434
45- const newHacker2 = util . hacker . newHacker2 ;
35+ const noTeamHackerAccount0 = util . account . hackerAccounts . stored . noTeam [ 0 ] ;
36+ const noTeamHacker0 = util . hacker . NoTeamHacker0 ;
37+
38+ const teamHackerAccount0 = util . account . hackerAccounts . stored . team [ 0 ] ;
39+ const TeamHacker0 = util . hacker . TeamHacker0 ;
40+ const duplicateAccountLinkHacker0 = util . hacker . duplicateAccountLinkHacker0 ;
41+
4642const invalidHacker1 = util . hacker . invalidHacker1 ;
4743
4844describe ( "GET hacker" , function ( ) {
4945 // fail on authentication
5046 it ( "should fail to list a hacker's information on /api/hacker/:id GET due to authentication" , function ( done ) {
5147 chai . request ( server . app )
52- . get ( `/api/hacker/` + storedHacker1 . _id )
48+ . get ( `/api/hacker/` + TeamHacker0 . _id )
5349 . end ( function ( err , res ) {
5450 res . should . have . status ( 401 ) ;
5551 res . should . be . json ;
@@ -78,7 +74,7 @@ describe("GET hacker", function () {
7874 res . body . message . should . equal ( Constants . Success . HACKER_READ ) ;
7975 res . body . should . have . property ( "data" ) ;
8076
81- let hacker = new Hacker ( storedHacker1 ) ;
77+ let hacker = new Hacker ( TeamHacker0 ) ;
8278 chai . assert . equal ( JSON . stringify ( res . body . data ) , JSON . stringify ( hacker . toJSON ( ) ) ) ;
8379 done ( ) ;
8480 } ) ;
@@ -112,7 +108,7 @@ describe("GET hacker", function () {
112108 return done ( error ) ;
113109 }
114110 return agent
115- . get ( `/api/hacker/${ storedHacker1 . _id } ` )
111+ . get ( `/api/hacker/${ TeamHacker0 . _id } ` )
116112 // does not have password because of to stripped json
117113 . end ( function ( err , res ) {
118114 if ( err ) {
@@ -124,7 +120,7 @@ describe("GET hacker", function () {
124120 res . body . message . should . equal ( Constants . Success . HACKER_READ ) ;
125121 res . body . should . have . property ( "data" ) ;
126122
127- let hacker = new Hacker ( storedHacker1 ) ;
123+ let hacker = new Hacker ( TeamHacker0 ) ;
128124 chai . assert . equal ( JSON . stringify ( res . body . data ) , JSON . stringify ( hacker . toJSON ( ) ) ) ;
129125
130126 done ( ) ;
@@ -140,7 +136,7 @@ describe("GET hacker", function () {
140136 return done ( error ) ;
141137 }
142138 return agent
143- . get ( `/api/hacker/${ storedHacker1 . _id } ` )
139+ . get ( `/api/hacker/${ TeamHacker0 . _id } ` )
144140 // does not have password because of to stripped json
145141 . end ( function ( err , res ) {
146142 if ( err ) {
@@ -152,7 +148,7 @@ describe("GET hacker", function () {
152148 res . body . message . should . equal ( Constants . Success . HACKER_READ ) ;
153149 res . body . should . have . property ( "data" ) ;
154150
155- let hacker = new Hacker ( storedHacker1 ) ;
151+ let hacker = new Hacker ( TeamHacker0 ) ;
156152
157153 chai . assert . equal ( JSON . stringify ( res . body . data ) , JSON . stringify ( hacker . toJSON ( ) ) ) ;
158154
@@ -169,7 +165,7 @@ describe("GET hacker", function () {
169165 return done ( error ) ;
170166 }
171167 return agent
172- . get ( `/api/hacker/${ storedHacker1 . _id } ` )
168+ . get ( `/api/hacker/${ TeamHacker0 . _id } ` )
173169 // does not have password because of to stripped json
174170 . end ( function ( err , res ) {
175171 if ( err ) {
@@ -239,7 +235,7 @@ describe("POST create hacker", function () {
239235 return agent
240236 . post ( `/api/hacker/` )
241237 . type ( "application/json" )
242- . send ( newHacker1 )
238+ . send ( newHacker0 )
243239 . end ( function ( err , res ) {
244240 res . should . have . status ( 200 ) ;
245241 res . should . be . json ;
@@ -250,7 +246,7 @@ describe("POST create hacker", function () {
250246 // create JSON version of model
251247 // delete id as they will be different between model objects
252248 // update status to be applied on the comparator hacker object
253- const hacker = ( new Hacker ( newHacker1 ) ) . toJSON ( ) ;
249+ const hacker = ( new Hacker ( newHacker0 ) ) . toJSON ( ) ;
254250 hacker . status = Constants . General . HACKER_STATUS_APPLIED ;
255251 delete res . body . data . id ;
256252 delete hacker . id ;
@@ -263,7 +259,7 @@ describe("POST create hacker", function () {
263259
264260 // succeed on user case
265261 it ( "should SUCCEED and create a new hacker for user (with an account that has been confirmed)" , function ( done ) {
266- util . auth . login ( agent , newHackerAccount1 , ( error ) => {
262+ util . auth . login ( agent , newHackerAccount0 , ( error ) => {
267263 if ( error ) {
268264 agent . close ( ) ;
269265 return done ( error ) ;
@@ -282,7 +278,7 @@ describe("POST create hacker", function () {
282278 // create JSON version of model
283279 // delete id as they will be different between model objects
284280 // update status to be applied on the comparator hacker object
285- const hacker = ( new Hacker ( newHacker1 ) ) . toJSON ( ) ;
281+ const hacker = ( new Hacker ( newHacker0 ) ) . toJSON ( ) ;
286282 hacker . status = Constants . General . HACKER_STATUS_APPLIED ;
287283 delete res . body . data . id ;
288284 delete hacker . id ;
@@ -294,15 +290,15 @@ describe("POST create hacker", function () {
294290
295291 // should fail due to 'false' on code of conduct
296292 it ( "should FAIL if the new hacker does not accept code of conduct" , function ( done ) {
297- util . auth . login ( agent , newHackerAccount1 , ( error ) => {
293+ util . auth . login ( agent , newHacker0 , ( error ) => {
298294 if ( error ) {
299295 agent . close ( ) ;
300296 return done ( error ) ;
301297 }
302298 return agent
303299 . post ( `/api/hacker/` )
304300 . type ( "application/json" )
305- . send ( badConductHacker1 )
301+ . send ( invalidHacker0 )
306302 . end ( function ( err , res ) {
307303 res . should . have . status ( 422 ) ;
308304 res . should . be . json ;
@@ -326,7 +322,7 @@ describe("POST create hacker", function () {
326322 return agent
327323 . post ( `/api/hacker/` )
328324 . type ( "application/json" )
329- . send ( newHacker2 )
325+ . send ( util . hacker . unconfirmedAccountHacker0 )
330326 . end ( function ( err , res ) {
331327 res . should . be . json ;
332328 res . body . should . have . property ( "message" ) ;
@@ -347,7 +343,7 @@ describe("POST create hacker", function () {
347343 return agent
348344 . post ( `/api/hacker/` )
349345 . type ( "application/json" )
350- . send ( newHackerDuplicateAccountLink1 )
346+ . send ( duplicateAccountLinkHacker0 )
351347 . end ( function ( err , res ) {
352348 res . should . have . status ( 409 ) ;
353349 res . body . should . have . property ( "message" ) ;
@@ -382,7 +378,7 @@ describe("PATCH update one hacker", function () {
382378 // fail on authentication
383379 it ( "should fail to update a hacker on /api/hacker/:id GET due to authentication" , function ( done ) {
384380 chai . request ( server . app )
385- . patch ( `/api/hacker/${ storedHacker1 . _id } ` )
381+ . patch ( `/api/hacker/${ TeamHacker0 . _id } ` )
386382 . type ( "application/json" )
387383 . send ( {
388384 gender : "Other"
@@ -404,7 +400,7 @@ describe("PATCH update one hacker", function () {
404400 return done ( error ) ;
405401 }
406402 return agent
407- . patch ( `/api/hacker/${ storedHacker1 . _id } ` )
403+ . patch ( `/api/hacker/${ TeamHacker0 . _id } ` )
408404 . type ( "application/json" )
409405 . send ( {
410406 gender : "Other"
@@ -430,7 +426,7 @@ describe("PATCH update one hacker", function () {
430426 return done ( error ) ;
431427 }
432428 return agent
433- . patch ( `/api/hacker/status/${ storedHacker1 . _id } ` )
429+ . patch ( `/api/hacker/status/${ TeamHacker0 . _id } ` )
434430 . type ( "application/json" )
435431 . send ( {
436432 status : "Accepted"
@@ -456,7 +452,7 @@ describe("PATCH update one hacker", function () {
456452 return done ( error ) ;
457453 }
458454 return agent
459- . patch ( `/api/hacker/status/${ storedHacker1 . _id } ` )
455+ . patch ( `/api/hacker/status/${ TeamHacker0 . _id } ` )
460456 . type ( "application/json" )
461457 . send ( {
462458 status : "Accepted"
@@ -480,7 +476,7 @@ describe("PATCH update one hacker", function () {
480476 return done ( error ) ;
481477 }
482478 return agent
483- . patch ( `/api/hacker/checkin/${ storedHacker1 . _id } ` )
479+ . patch ( `/api/hacker/checkin/${ TeamHacker0 . _id } ` )
484480 . type ( "application/json" )
485481 . send ( {
486482 status : "Checked-in"
@@ -507,7 +503,7 @@ describe("PATCH update one hacker", function () {
507503 return done ( error ) ;
508504 }
509505 return agent
510- . patch ( `/api/hacker/checkin/${ storedHacker1 . _id } ` )
506+ . patch ( `/api/hacker/checkin/${ TeamHacker0 . _id } ` )
511507 . type ( "application/json" )
512508 . send ( {
513509 status : "Checked-in"
@@ -531,7 +527,7 @@ describe("PATCH update one hacker", function () {
531527 return done ( error ) ;
532528 }
533529 return agent
534- . patch ( `/api/hacker/${ storedHacker2 . _id } ` )
530+ . patch ( `/api/hacker/${ noTeamHacker0 . _id } ` )
535531 . type ( "application/json" )
536532 . send ( {
537533 gender : "Other"
@@ -558,7 +554,7 @@ describe("PATCH update one hacker", function () {
558554 return done ( error ) ;
559555 }
560556 return agent
561- . patch ( `/api/hacker/${ storedHacker1 . _id } ` )
557+ . patch ( `/api/hacker/${ noTeamHacker0 . _id } ` )
562558 . type ( "application/json" )
563559 . send ( {
564560 gender : "Other"
@@ -607,7 +603,7 @@ describe("PATCH update one hacker", function () {
607603 return done ( error ) ;
608604 }
609605 return agent
610- . patch ( `/api/hacker/confirmation/${ storedHacker2 . _id } ` )
606+ . patch ( `/api/hacker/confirmation/${ noTeamHacker0 . _id } ` )
611607 . type ( "application/json" )
612608 . send ( {
613609 confirm : true
@@ -638,7 +634,7 @@ describe("PATCH update one hacker", function () {
638634 return done ( error ) ;
639635 }
640636 return agent
641- . patch ( `/api/hacker/confirmation/${ storedHacker1 . _id } ` )
637+ . patch ( `/api/hacker/confirmation/${ noTeamHacker0 . _id } ` )
642638 . type ( "application/json" )
643639 . send ( {
644640 confirm : false
@@ -697,7 +693,7 @@ describe("PATCH update one hacker", function () {
697693 return done ( error ) ;
698694 }
699695 return agent
700- . patch ( `/api/hacker/confirmation/${ storedHacker1 . _id } ` )
696+ . patch ( `/api/hacker/confirmation/${ noTeamHacker0 . _id } ` )
701697 . type ( "application/json" )
702698 . send ( {
703699 confirm : true
@@ -720,12 +716,12 @@ describe("PATCH update one hacker", function () {
720716describe ( "POST add a hacker resume" , function ( ) {
721717 it ( "It should SUCCEED and upload a resume for a hacker" , function ( done ) {
722718 //this takes a lot of time for some reason
723- util . auth . login ( agent , storedHacker1 , ( error ) => {
719+ util . auth . login ( agent , noTeamHacker0 , ( error ) => {
724720 if ( error ) {
725721 return done ( error ) ;
726722 }
727723 return agent
728- . post ( `/api/hacker/resume/${ storedHacker1 . _id } ` )
724+ . post ( `/api/hacker/resume/${ noTeamHacker0 . _id } ` )
729725 . type ( "multipart/form-data" )
730726 . attach ( "resume" , fs . createReadStream ( path . join ( __dirname , "testResume.pdf" ) ) , {
731727 contentType : "application/pdf"
0 commit comments