mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
WIP(hourglass): Error catches
This commit is contained in:
@@ -15,7 +15,8 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
user = {
|
||||
items: {
|
||||
pets: {},
|
||||
mounts: {}
|
||||
mounts: {},
|
||||
hatchingPotions: {}
|
||||
},
|
||||
purchased: {
|
||||
plan: {
|
||||
@@ -33,8 +34,16 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
|
||||
context('failure conditions', function() {
|
||||
|
||||
it('does not allow purchase of unsupported item types', function(done) {
|
||||
user.ops.hourglassPurchase({params:{type: 'hatchingPotions', key: 'Base'}}, function(response) {
|
||||
expect(response.message).to.eql("Item type not supported for purchase with Mystic Hourglass. Allowed types: [pets, mounts]");
|
||||
expect(user.items.hatchingPotions).to.eql({});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant pets without Mystic Hourglasses', function(done) {
|
||||
user.ops.hourglassPurchase({params:{category: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params:{type: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("You don't have enough Mystic Hourglasses.");
|
||||
expect(user.items.pets).to.eql({});
|
||||
done();
|
||||
@@ -42,20 +51,20 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
});
|
||||
|
||||
it('does not grant mounts without Mystic Hourglasses', function(done) {
|
||||
user.ops.hourglassPurchase({params:{category: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params:{type: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("You don't have enough Mystic Hourglasses.");
|
||||
expect(user.items.mounts).to.eql({});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('does not grant pet that has already been purchased', function(done) {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.pets = {
|
||||
'MantisShrimp-Base': true
|
||||
};
|
||||
};
|
||||
|
||||
user.ops.hourglassPurchase({params:{category: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params:{type: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("Pet already owned.");
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
@@ -66,9 +75,9 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.mounts = {
|
||||
'MantisShrimp-Base': true
|
||||
};
|
||||
};
|
||||
|
||||
user.ops.hourglassPurchase({params:{category: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params:{type: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("Mount already owned.");
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
@@ -78,7 +87,7 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
it('does not grant pet that is not part of the Time Travel Stable', function(done) {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
user.ops.hourglassPurchase({params: {category: 'pets', key: 'Wolf-Veteran'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'Wolf-Veteran'}}, function(response) {
|
||||
expect(response.message).to.eql('Pet not available for purchase with Mystic Hourglass.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
@@ -88,7 +97,7 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
it('does not grant mount that is not part of the Time Travel Stable', function(done) {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
user.ops.hourglassPurchase({params: {category: 'mounts', key: 'Orca-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'Orca-Base'}}, function(response) {
|
||||
expect(response.message).to.eql('Mount not available for purchase with Mystic Hourglass.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
@@ -101,7 +110,7 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
it('buys a pet', function(done) {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
user.ops.hourglassPurchase({params: {category: 'pets', key: 'MantisShrimp-Base'}}, function() {
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'MantisShrimp-Base'}}, function() {
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.pets).to.eql({'MantisShrimp-Base':true});
|
||||
done();
|
||||
@@ -111,7 +120,7 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
it('buys a mount', function(done) {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
user.ops.hourglassPurchase({params: {category: 'mounts', key: 'MantisShrimp-Base'}}, function() {
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, function() {
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.mounts).to.eql({'MantisShrimp-Base':true});
|
||||
done();
|
||||
@@ -120,4 +129,3 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user