mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Discount Bundled Quests (#8731)
* refactor(content): split quests file * feat(purchases): sell bundled quests * fix(style): address linting errors * test(bundles): shop and purchase tests * fix(test): remove only * test(bundles): check balance deduction * docs(content): comment bundle structure * fix(test): account for cumulative balance
This commit is contained in:
@@ -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,28 @@ describe('shared.ops.purchase', () => {
|
||||
|
||||
expect(user.items.gear.owned[key]).to.be.true;
|
||||
});
|
||||
|
||||
it('purchases quest bundles', () => {
|
||||
let startingBalance = user.balance;
|
||||
let clock = sandbox.useFakeTimers(moment('2017-05-20').valueOf());
|
||||
let type = 'bundles';
|
||||
let key = 'featheredFriends';
|
||||
let price = 1.75;
|
||||
let questList = [
|
||||
'falcon',
|
||||
'harpy',
|
||||
'owl',
|
||||
];
|
||||
|
||||
purchase(user, {params: {type, key}});
|
||||
|
||||
forEach(questList, (bundledKey) => {
|
||||
expect(user.items.quests[bundledKey]).to.equal(1);
|
||||
});
|
||||
|
||||
expect(user.balance).to.equal(startingBalance - price);
|
||||
|
||||
clock.restore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user