mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
tests: Update updateStats test
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user