mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix(modals): Show mount modal more often
Fixes #6288. Previously, we used a count of all properties within the user's items.pets.mounts to determine whether or not they'd gained a new mount. That would not work as expected if they had mounts with a null or false status, such as after using the Key to the Kennels. This commit also adds some tests to the inventory controller in Angular for pet raising.
This commit is contained in:
@@ -88,6 +88,82 @@ describe('Inventory Controller', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Feeding and Raising Pets', function() {
|
||||
beforeEach(function() {
|
||||
sandbox.stub(rootScope, 'openModal');
|
||||
user.items.pets = {'PandaCub-Base':5};
|
||||
user.items.mounts = {'PandaCub-Base':false};
|
||||
});
|
||||
|
||||
it('feeds a pet', function() {
|
||||
scope.chooseFood('Meat');
|
||||
scope.choosePet('PandaCub','Base');
|
||||
|
||||
expect(user.items.pets['PandaCub-Base']).to.eql(10);
|
||||
});
|
||||
|
||||
it('gives weaker benefit when feeding inappropriate food', function() {
|
||||
user.items.food.Honey = 1;
|
||||
|
||||
scope.chooseFood('Honey');
|
||||
scope.choosePet('PandaCub','Base');
|
||||
|
||||
expect(user.items.pets['PandaCub-Base']).to.eql(7);
|
||||
});
|
||||
|
||||
it('raises pet to a mount when feeding gauge maxes out', function() {
|
||||
user.items.pets['PandaCub-Base'] = 45;
|
||||
|
||||
scope.chooseFood('Meat');
|
||||
scope.choosePet('PandaCub','Base');
|
||||
|
||||
expect(user.items.pets['PandaCub-Base']).to.eql(-1);
|
||||
expect(user.items.mounts['PandaCub-Base']).to.exist;
|
||||
});
|
||||
|
||||
it('raises pet to a mount instantly when using a Saddle', function() {
|
||||
user.items.food.Saddle = 1;
|
||||
|
||||
scope.chooseFood('Saddle');
|
||||
scope.choosePet('PandaCub','Base');
|
||||
|
||||
expect(user.items.pets['PandaCub-Base']).to.eql(-1);
|
||||
expect(user.items.mounts['PandaCub-Base']).to.exist;
|
||||
});
|
||||
|
||||
it('displays mount raising modal for drop pets', function() {
|
||||
user.items.food.Saddle = 1;
|
||||
|
||||
scope.chooseFood('Saddle');
|
||||
scope.choosePet('PandaCub','Base');
|
||||
|
||||
expect(rootScope.openModal).to.have.been.calledOnce;
|
||||
expect(rootScope.openModal).to.have.been.calledWith('raisePet');
|
||||
});
|
||||
|
||||
it('displays mount raising modal for quest pets', function() {
|
||||
user.items.food.Saddle = 1;
|
||||
user.items.pets['Snake-Base'] = 1;
|
||||
|
||||
scope.chooseFood('Saddle');
|
||||
scope.choosePet('Snake','Base');
|
||||
|
||||
expect(rootScope.openModal).to.have.been.calledOnce;
|
||||
expect(rootScope.openModal).to.have.been.calledWith('raisePet');
|
||||
});
|
||||
|
||||
it('displays mount raising modal for premium pets', function() {
|
||||
user.items.food.Saddle = 1;
|
||||
user.items.pets['TigerCub-Spooky'] = 1;
|
||||
|
||||
scope.chooseFood('Saddle');
|
||||
scope.choosePet('TigerCub','Spooky');
|
||||
|
||||
expect(rootScope.openModal).to.have.been.calledOnce;
|
||||
expect(rootScope.openModal).to.have.been.calledWith('raisePet');
|
||||
});
|
||||
});
|
||||
|
||||
it('sells an egg', function(){
|
||||
scope.chooseEgg('Cactus');
|
||||
scope.sellInventory();
|
||||
|
||||
Reference in New Issue
Block a user