@@ -36,6 +36,9 @@ const storedAccount2 = util.account.Account2;
3636const storedHacker2 = util . hacker . HackerB ;
3737
3838const 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 ;
3942const newHackerAccount1 = util . account . allAccounts [ 13 ] ;
4043
4144const 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 ) => {
0 commit comments