mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-12 23:08:35 +00:00
Add method to get user balance in gems
This commit is contained in:
parent
061e381abf
commit
791e2f0c16
2 changed files with 22 additions and 0 deletions
|
|
@ -194,6 +194,11 @@ angular.module('habitrpg')
|
|||
return this.settings.auth.apiId !== "";
|
||||
},
|
||||
|
||||
getBalanceInGems: function() {
|
||||
var balance = user.balance || 0;
|
||||
return balance * 4;
|
||||
},
|
||||
|
||||
log: function (action, cb) {
|
||||
//push by one buy one if an array passed in.
|
||||
if (_.isArray(action)) {
|
||||
|
|
|
|||
|
|
@ -46,4 +46,21 @@ describe('userServices', function() {
|
|||
//TODO where does that null comes from?
|
||||
expect(user.settings.sync.queue).to.eql([null, {}]);
|
||||
});
|
||||
|
||||
describe('getBalanceInGems', function() {
|
||||
|
||||
it('multiplies balance by 4', function() {
|
||||
user.user.balance = 5;
|
||||
var balanceInGems = user.getBalanceInGems();
|
||||
|
||||
expect(balanceInGems).to.eql(20);
|
||||
});
|
||||
|
||||
it('returns zero if balance is not defined', function() {
|
||||
var balanceInGems = user.getBalanceInGems();
|
||||
|
||||
expect(user.user.balance).to.not.exist;
|
||||
expect(balanceInGems).to.eql(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue