test(bundles): shop and purchase tests

This commit is contained in:
SabreCat 2017-05-17 19:37:19 +00:00
parent 4de5b4253b
commit 8555e4bea8
3 changed files with 47 additions and 4 deletions

View file

@ -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')

View file

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

View file

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