mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 16:02:14 +00:00
Move cs tests to js
This commit is contained in:
parent
6e68450309
commit
0c82d757c8
2 changed files with 71 additions and 42 deletions
|
|
@ -394,44 +394,6 @@ describe 'User', ->
|
|||
}
|
||||
|
||||
describe 'store', ->
|
||||
it 'recovers hp buying potions', ->
|
||||
user = newUser()
|
||||
user.stats.hp = 30
|
||||
user.stats.gp = 50
|
||||
user.ops.buy {params: {key: 'potion'}}
|
||||
expect(user).toHaveHP 45
|
||||
expect(user).toHaveGP 25
|
||||
|
||||
user.ops.buy {params: {key: 'potion'}}
|
||||
expect(user).toHaveHP 50 # don't exceed max hp
|
||||
expect(user).toHaveGP 0
|
||||
|
||||
it 'buys equipment', ->
|
||||
user = newUser()
|
||||
user.stats.gp = 31
|
||||
user.ops.buy {params: {key: 'armor_warrior_1'}}
|
||||
expect(user.items.gear.owned).to.eql { weapon_warrior_0: true, armor_warrior_1: true }
|
||||
expect(user.items.gear.equipped).to.eql { armor: 'armor_warrior_1', weapon: 'weapon_base_0', head: 'head_base_0', shield: 'shield_base_0' }
|
||||
expect(user).toHaveGP 1
|
||||
|
||||
it 'buys equipment but does not auto-equip', ->
|
||||
user = newUser()
|
||||
user.stats.gp = 31
|
||||
user.preferences.autoEquip = false
|
||||
user.ops.buy {params: {key: 'armor_warrior_1'}}
|
||||
expect(user.items.gear.owned).to.eql { weapon_warrior_0: true, armor_warrior_1: true }
|
||||
expect(user.items.gear.equipped).to.eql { armor: 'armor_base_0', weapon: 'weapon_base_0', head: 'head_base_0', shield: 'shield_base_0' }
|
||||
expect(user).toHaveGP 1
|
||||
|
||||
|
||||
|
||||
it 'does not buy equipment without enough Gold', ->
|
||||
user = newUser()
|
||||
user.stats.gp = 1
|
||||
user.ops.buy {params: {key: 'armor_warrior_1'}}
|
||||
expect(user.items.gear.equipped).to.eql { armor: 'armor_base_0', weapon: 'weapon_base_0', head: 'head_base_0', shield: 'shield_base_0' }
|
||||
expect(user).toHaveGP 1
|
||||
|
||||
it 'buys a Quest scroll', ->
|
||||
user = newUser()
|
||||
user.stats.gp = 205
|
||||
|
|
|
|||
|
|
@ -16,9 +16,13 @@ describe('user.fns.buy', function() {
|
|||
gear: {
|
||||
owned: {
|
||||
weapon_warrior_0: true
|
||||
},
|
||||
equipped: {
|
||||
weapon_warrior_0: true
|
||||
}
|
||||
}
|
||||
},
|
||||
preferences: {},
|
||||
stats: { gp: 200 },
|
||||
achievements: { },
|
||||
flags: { }
|
||||
|
|
@ -36,14 +40,77 @@ describe('user.fns.buy', function() {
|
|||
});
|
||||
|
||||
context('Potion', function() {
|
||||
it('recovers hp');
|
||||
it('recovers 15 hp', function() {
|
||||
user.stats.hp = 30;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
expect(user.stats.hp).to.eql(45);
|
||||
});
|
||||
|
||||
it('does not increase hp above 50', function() {
|
||||
user.stats.hp = 45;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
expect(user.stats.hp).to.eql(50);
|
||||
});
|
||||
|
||||
it('deducts 25 gp', function() {
|
||||
user.stats.hp = 45;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
|
||||
expect(user.stats.gp).to.eql(175);
|
||||
});
|
||||
|
||||
it('does not purchase if not enough gp', function() {
|
||||
user.stats.hp = 45;
|
||||
user.stats.gp = 5;
|
||||
user.ops.buy({params: {key: 'potion'}});
|
||||
|
||||
expect(user.stats.hp).to.eql(45);
|
||||
expect(user.stats.gp).to.eql(5);
|
||||
});
|
||||
});
|
||||
|
||||
context('Gear', function() {
|
||||
it('buys equipment');
|
||||
it('buys equipment but does not auto-equip');
|
||||
it('adds equipment to inventory', function() {
|
||||
user.stats.gp = 31;
|
||||
|
||||
it('does not buy equipment without enough Gold');
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.owned).to.eql({ weapon_warrior_0: true, armor_warrior_1: true });
|
||||
});
|
||||
|
||||
it('deducts gold from user', function() {
|
||||
user.stats.gp = 31;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.stats.gp).to.eql(1);
|
||||
});
|
||||
|
||||
it('auto equips equipment if user has auto-equip preference turned on', function() {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = true;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.have.property('armor', 'armor_warrior_1');
|
||||
});
|
||||
|
||||
it('buys equipment but does not auto-equip', function() {
|
||||
user.stats.gp = 31;
|
||||
user.preferences.autoEquip = false;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.equipped).to.not.have.property('armor');
|
||||
});
|
||||
|
||||
it('does not buy equipment without enough Gold', function() {
|
||||
user.stats.gp = 20;
|
||||
|
||||
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||
|
||||
expect(user.items.gear.owned).to.not.have.property('armor_warrior_1');
|
||||
});
|
||||
});
|
||||
|
||||
context('Quests', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue