mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
(chore): lint test/common files
This commit is contained in:
@@ -1,101 +1,93 @@
|
||||
var sinon = require('sinon');
|
||||
var chai = require("chai")
|
||||
chai.use(require("sinon-chai"))
|
||||
var expect = chai.expect
|
||||
let shared = require('../../common/script/index.js');
|
||||
|
||||
var shared = require('../../common/script/index.js');
|
||||
var Content = require('../../common/script/content/index.js');
|
||||
describe('user.ops.hourglassPurchase', () => {
|
||||
let user;
|
||||
|
||||
describe('user.ops.hourglassPurchase', function() {
|
||||
var user;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(() => {
|
||||
user = {
|
||||
items: {
|
||||
pets: {},
|
||||
mounts: {},
|
||||
hatchingPotions: {}
|
||||
hatchingPotions: {},
|
||||
},
|
||||
purchased: {
|
||||
plan: {
|
||||
consecutive: {
|
||||
trinkets: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
trinkets: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
shared.wrap(user);
|
||||
});
|
||||
|
||||
context('Time Travel Stable', 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) {
|
||||
context('Time Travel Stable', () => {
|
||||
context('failure conditions', () => {
|
||||
it('does not allow purchase of unsupported item types', (done) => {
|
||||
user.ops.hourglassPurchase({params: {type: 'hatchingPotions', key: 'Base'}}, (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:{type: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("You don't have enough Mystic Hourglasses.");
|
||||
it('does not grant pets without Mystic Hourglasses', (done) => {
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'MantisShrimp-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('You don\'t have enough Mystic Hourglasses.');
|
||||
expect(user.items.pets).to.eql({});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant mounts without Mystic Hourglasses', function(done) {
|
||||
user.ops.hourglassPurchase({params:{type: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("You don't have enough Mystic Hourglasses.");
|
||||
it('does not grant mounts without Mystic Hourglasses', (done) => {
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (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) {
|
||||
it('does not grant pet that has already been purchased', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.pets = {
|
||||
'MantisShrimp-Base': true
|
||||
'MantisShrimp-Base': true,
|
||||
};
|
||||
|
||||
user.ops.hourglassPurchase({params:{type: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("Pet already owned.");
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'MantisShrimp-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('Pet already owned.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant mount that has already been purchased', function(done) {
|
||||
it('does not grant mount that has already been purchased', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
user.items.mounts = {
|
||||
'MantisShrimp-Base': true
|
||||
'MantisShrimp-Base': true,
|
||||
};
|
||||
|
||||
user.ops.hourglassPurchase({params:{type: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
expect(response.message).to.eql("Mount already owned.");
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('Mount already owned.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant pet that is not part of the Time Travel Stable', function(done) {
|
||||
it('does not grant pet that is not part of the Time Travel Stable', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'Wolf-Veteran'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'Wolf-Veteran'}}, (response) => {
|
||||
expect(response.message).to.eql('Pet not available for purchase with Mystic Hourglass.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not grant mount that is not part of the Time Travel Stable', function(done) {
|
||||
it('does not grant mount that is not part of the Time Travel Stable', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 1;
|
||||
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'Orca-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'Orca-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('Mount not available for purchase with Mystic Hourglass.');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
done();
|
||||
@@ -103,26 +95,25 @@ describe('user.ops.hourglassPurchase', function() {
|
||||
});
|
||||
});
|
||||
|
||||
context('successful purchases', function() {
|
||||
|
||||
it('buys a pet', function(done) {
|
||||
context('successful purchases', () => {
|
||||
it('buys a pet', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'pets', key: 'MantisShrimp-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('Purchased an item using a Mystic Hourglass!');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.pets).to.eql({'MantisShrimp-Base':5});
|
||||
expect(user.items.pets).to.eql({'MantisShrimp-Base': 5});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('buys a mount', function(done) {
|
||||
it('buys a mount', (done) => {
|
||||
user.purchased.plan.consecutive.trinkets = 2;
|
||||
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, function(response) {
|
||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (response) => {
|
||||
expect(response.message).to.eql('Purchased an item using a Mystic Hourglass!');
|
||||
expect(user.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(user.items.mounts).to.eql({'MantisShrimp-Base':true});
|
||||
expect(user.items.mounts).to.eql({'MantisShrimp-Base': true});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user