test(hourglass): TDD for Time Travel filtering

This commit is contained in:
Sabe Jones
2015-09-16 15:27:19 -04:00
parent c8cc01fc44
commit 3bfeb15715
2 changed files with 50 additions and 6 deletions

View File

@@ -59,8 +59,8 @@
"timeTravelers": "Time Travelers",
"timeTravelersTitleNoSub": "<%= linkStartTyler %>Tyler<%= linkEnd %> and <%= linkStartVicky %>Vicky<%= linkEnd %>",
"timeTravelersTitle": "Mysterious Time Travelers",
"timeTravelersPopoverNoSub": "You'll need a Mystic Hourglass to summon the mysterious Time Travelers! <%= linkStart %>Subscribers<%= linkEnd %> earn one Mystic Hourglass for every three months of consecutive subscribing. Come back when you have a Mystic Hourglass, and the Time Travelers will fetch you a Subscriber Item Set from the past.... or maybe even the future.",
"timeTravelersPopover": "We see you have a Mystic Hourglass, so we will happily travel back in time for you! Please choose the Mystery Item Set you would like. You can see a list of the past item sets <%= linkStart %>here<%= linkEnd %>! If those don't satisfy you, perhaps you'd be interested in one of our fashionably futuristic Steampunk Item Sets?",
"timeTravelersPopoverNoSub": "You'll need a Mystic Hourglass to summon the mysterious Time Travelers! <%= linkStart %>Subscribers<%= linkEnd %> earn one Mystic Hourglass for every three months of consecutive subscribing. Come back when you have a Mystic Hourglass, and the Time Travelers will fetch you a rare pet, mount, or Subscriber Item Set from the past... or maybe even the future.",
"timeTravelersPopover": "We see you have a Mystic Hourglass, so we will happily travel back in time for you! Please choose the pet, mount, or Mystery Item Set you would like. You can see a list of the past item sets <%= linkStart %>here<%= linkEnd %>! If those don't satisfy you, perhaps you'd be interested in one of our fashionably futuristic Steampunk Item Sets?",
"timeTravelersAlreadyOwned": "Congratulations! You already own all of the Mystery Items. Thanks for supporting the site!",
"mysticHourglassPopover": "Mystic Hourglass allows you to purchase previous months' subscriber sets.",
"subUpdateCard": "Update Card",

View File

@@ -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);
});
});
});