From 8555e4bea807bfff3ca033d73e1bc239e66f0390 Mon Sep 17 00:00:00 2001 From: SabreCat Date: Wed, 17 May 2017 19:37:19 +0000 Subject: [PATCH] test(bundles): shop and purchase tests --- .../spec/services/questServicesSpec.js | 14 +++++++++++++ test/common/libs/shops.js | 16 ++++++++++---- test/common/ops/purchase.js | 21 +++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/test/client-old/spec/services/questServicesSpec.js b/test/client-old/spec/services/questServicesSpec.js index e71dc6f3ef..a48e00ffe4 100644 --- a/test/client-old/spec/services/questServicesSpec.js +++ b/test/client-old/spec/services/questServicesSpec.js @@ -206,6 +206,20 @@ describe('Quests Service', function() { }); }); + context('quest bundles', function() { + it('sends bundle object', function(done) { + questsService.buyQuest('featheredFriends') + .then(function(res) { + expect(res).to.eql(content.bundles.featheredFriends); + expect(window.alert).to.not.be.called; + expect(rejectSpy).to.not.be.called; + done(); + }, rejectSpy); + + scope.$apply(); + }); + }); + context('all other quests', function() { it('sends quest object', function(done) { questsService.buyQuest('whale') diff --git a/test/common/libs/shops.js b/test/common/libs/shops.js index 396e394169..5def960c29 100644 --- a/test/common/libs/shops.js +++ b/test/common/libs/shops.js @@ -47,11 +47,19 @@ describe('shops', () => { it('items contain required fields', () => { _.each(shopCategories, (category) => { - _.each(category.items, (item) => { - _.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'boss', 'class', 'collect', 'drop', 'unlockCondition', 'lvl'], (key) => { - expect(_.has(item, key)).to.eql(true); + if (category.identifier === 'bundle') { + _.each(category.items, (item) => { + _.each(['key', 'text', 'notes', 'value', 'currency', 'purchaseType', 'class'], (key) => { + expect(_.has(item, key)).to.eql(true); + }); }); - }); + } else { + _.each(category.items, (item) => { + _.each(['key', 'text', 'notes', 'value', 'currency', 'locked', 'purchaseType', 'boss', 'class', 'collect', 'drop', 'unlockCondition', 'lvl'], (key) => { + expect(_.has(item, key)).to.eql(true); + }); + }); + } }); }); }); diff --git a/test/common/ops/purchase.js b/test/common/ops/purchase.js index f7ed21e0e1..0b4e4cbc19 100644 --- a/test/common/ops/purchase.js +++ b/test/common/ops/purchase.js @@ -9,6 +9,8 @@ import i18n from '../../../website/common/script/i18n'; import { generateUser, } from '../../helpers/common.helper'; +import forEach from 'lodash/forEach'; +import moment from 'moment'; describe('shared.ops.purchase', () => { const SEASONAL_FOOD = 'Meat'; @@ -200,5 +202,24 @@ describe('shared.ops.purchase', () => { expect(user.items.gear.owned[key]).to.be.true; }); + + it.only('purchases quest bundles', () => { + let clock = sandbox.useFakeTimers(+moment('2017-05-20')); + let type = 'bundles'; + let key = 'featheredFriends'; + let questList = [ + 'falcon', + 'harpy', + 'owl', + ]; + + purchase(user, {params: {type, key}}); + + forEach(questList, (bundledKey) => { + expect(user.items.quests[bundledKey]).to.equal(1); + }); + + clock.restore(); + }); }); });