Skip to content

Commit

Permalink
test(bundles): shop and purchase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreCat committed May 17, 2017
1 parent 7353aa7 commit 6feba59
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
14 changes: 14 additions & 0 deletions test/client-old/spec/services/questServicesSpec.js
Expand Up @@ -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')
Expand Down
16 changes: 12 additions & 4 deletions test/common/libs/shops.js
Expand Up @@ -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);
});
});
}
});
});
});
Expand Down
21 changes: 21 additions & 0 deletions test/common/ops/purchase.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
});
});
});

0 comments on commit 6feba59

Please sign in to comment.