2015-11-20 02:27:39 +00:00
/* eslint-disable prefer-template, no-shadow, func-names */
2015-11-15 03:44:10 +00:00
2019-10-08 18:45:38 +00:00
const expect = require ( 'expect.js' ) ;
2015-11-20 02:27:39 +00:00
module . exports . addCustomMatchers = function ( ) {
2019-10-08 18:45:38 +00:00
const { Assertion } = expect ;
2015-11-20 02:27:39 +00:00
Assertion . prototype . toHaveGP = function ( gp ) {
2019-10-08 18:45:38 +00:00
const actual = this . obj . stats . gp ;
return this . assert ( actual === gp , ( ) => 'expected user to have ' + gp + ' gp, but got ' + actual , ( ) => 'expected user to not have ' + gp + ' gp' ) ;
2015-11-15 03:44:10 +00:00
} ;
2015-11-20 02:27:39 +00:00
Assertion . prototype . toHaveHP = function ( hp ) {
2019-10-08 18:45:38 +00:00
const actual = this . obj . stats . hp ;
return this . assert ( actual === hp , ( ) => 'expected user to have ' + hp + ' hp, but got ' + actual , ( ) => 'expected user to not have ' + hp + ' hp' ) ;
2015-11-15 03:44:10 +00:00
} ;
2015-11-20 02:27:39 +00:00
Assertion . prototype . toHaveExp = function ( exp ) {
2019-10-08 18:45:38 +00:00
const actual = this . obj . stats . exp ;
return this . assert ( actual === exp , ( ) => 'expected user to have ' + exp + ' experience points, but got ' + actual , ( ) => 'expected user to not have ' + exp + ' experience points' ) ;
2015-11-15 03:44:10 +00:00
} ;
2015-11-20 02:27:39 +00:00
Assertion . prototype . toHaveLevel = function ( lvl ) {
2019-10-08 18:45:38 +00:00
const actual = this . obj . stats . lvl ;
return this . assert ( actual === lvl , ( ) => 'expected user to be level ' + lvl + ', but got ' + actual , ( ) => 'expected user to not be level ' + lvl ) ;
2015-11-15 03:44:10 +00:00
} ;
2015-11-20 02:27:39 +00:00
Assertion . prototype . toHaveMaxMP = function ( mp ) {
2019-10-08 18:45:38 +00:00
const actual = this . obj . _statsComputed . maxMP ;
return this . assert ( actual === mp , ( ) => 'expected user to have ' + mp + ' max mp, but got ' + actual , ( ) => 'expected user to not have ' + mp + ' max mp' ) ;
2015-11-15 03:44:10 +00:00
} ;
} ;