tests: Update updateStats test

This commit is contained in:
Blade Barringer
2015-12-26 19:52:25 -06:00
parent 1b118d86b2
commit 80ed048d5c
2 changed files with 41 additions and 16 deletions

View File

@@ -6,40 +6,66 @@ describe('user.fns.updateStats', () => {
let user;
beforeEach(() => {
user = generateUser({
stats: {
int: 20,
str: 20,
con: 20,
per: 20,
lvl: 20,
},
user = generateUser({});
});
context('no hp', () => {
it('returns 0 if user\'s hp is 0', () => {
let stats = {
hp: 0,
};
expect(user.fns.updateStats(stats)).to.eql(0);
});
it('returns 0 if user\'s hp is less than 0', () => {
let stats = {
hp: -5,
};
expect(user.fns.updateStats(stats)).to.eql(0);
});
it('sets user\'s hp to 0 if it is less than 0', () => {
let stats = {
hp: -5,
};
user.fns.updateStats(stats)
expect(user.stats.hp).to.eql(0);
});
});
context('Stat Allocation', () => {
it('adds an attibute point when user\'s stat points are less than max level', () => {
user.stats.exp = 3581;
it('Adds an attibute point when user\'s stat points are less than max level', () => {
let stats = {
exp: 3581,
};
user.stats.lvl = 99;
user.stats.str = 25;
user.stats.int = 25;
user.stats.con = 25;
user.stats.per = 24;
user.fns.updateStats(user.stats);
user.fns.updateStats(stats);
expect(user.stats.points).to.eql(1);
});
it('does not add an attibute point when user\'s stat points are equal to max level', () => {
user.stats.exp = 3581;
it('Does not add an attibute point when user\'s stat points are equal to max level', () => {
let stats = {
exp: 3581,
};
user.stats.lvl = 99;
user.stats.str = 25;
user.stats.int = 25;
user.stats.con = 25;
user.stats.per = 25;
user.fns.updateStats(user.stats);
user.fns.updateStats(stats);
expect(user.stats.points).to.eql(0);
});