mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
test(hourglass): TDD for Time Travel filtering
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
|
||||
describe('Inventory Controller', function() {
|
||||
var scope, ctrl, user, rootScope;
|
||||
|
||||
@@ -224,14 +226,56 @@ describe('Inventory Controller', function() {
|
||||
});
|
||||
|
||||
describe('#hasAllTimeTravelerItems', function() {
|
||||
it('returns false if there are items left in the time traveler store', function() {
|
||||
expect(scope.hasAllTimeTravelerItems()).to.eql(false);
|
||||
it('returns false if items remain for purchase with Mystic Hourglasses', function() {
|
||||
expect(scope.hasAllTimeTravelerItems).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true if there are no items left to purchase', inject(function(Content) {
|
||||
it('returns true if no more items remain for purchase with Mystic Hourglasses', function() {
|
||||
sandbox.stub(Content, 'timeTravelerStore').returns({});
|
||||
_.forEach(Content.timeTravelStable.pets, function(v,k) {
|
||||
user.items.pets[k] = 5;
|
||||
});
|
||||
_.forEach(Content.timeTravelStable.mounts, function(v,k) {
|
||||
user.items.mounts[k] = true;
|
||||
});
|
||||
|
||||
expect(scope.hasAllTimeTravelerItems).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#hasAllTimeTravelerItemsOfType', function() {
|
||||
it('returns false for Mystery Sets if there are sets left in the time traveler store', function() {
|
||||
expect(scope.hasAllTimeTravelerItemsOfType('mystery')).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true for Mystery Sets if there are no sets left to purchase', inject(function(Content) {
|
||||
sandbox.stub(Content, 'timeTravelerStore').returns({});
|
||||
|
||||
expect(scope.hasAllTimeTravelerItems()).to.eql(true);
|
||||
expect(scope.hasAllTimeTravelerItems('mystery')).to.eql(true);
|
||||
}));
|
||||
|
||||
it('returns false for pets if user does not own all pets in the Time Travel Stable', function() {
|
||||
expect(scope.hasAllTimeTravelerItemsOfType('pets')).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true for pets if user owns all pets in the Time Travel Stable', function() {
|
||||
_.forEach(Content.timeTravelStable.pets, function(v,k) {
|
||||
user.items.pets[k] = 5;
|
||||
});
|
||||
|
||||
expect(scope.hasAllTimeTravelerItemsOfType('pets')).to.eql(true);
|
||||
});
|
||||
|
||||
it('returns false for mounts if user does not own all mounts in the Time Travel Stable', function() {
|
||||
expect(scope.hasAllTimeTravelerItemsOfType('mounts')).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true for mounts if user owns all mounts in the Time Travel Stable', function() {
|
||||
_.forEach(Content.timeTravelStable.mounts, function(v,k) {
|
||||
user.items.mounts[k] = true;
|
||||
});
|
||||
|
||||
expect(scope.hasAllTimeTravelerItemsOfType('mounts')).to.eql(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user