mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-21 21:34:15 +00:00
Fix mystery set award to new subscribers (#7586)
* fix(mystery): flip da sign * test(subscription): check mystery box
This commit is contained in:
parent
afea917409
commit
6084ea2017
2 changed files with 16 additions and 1 deletions
|
|
@ -9,8 +9,17 @@ describe('payments/index', () => {
|
|||
let user;
|
||||
|
||||
describe('#createSubscription', () => {
|
||||
const MYSTERY_AWARD_COUNT = 2;
|
||||
const MYSTERY_AWARD_UNIX_TIME = 1464725113000;
|
||||
let fakeClock;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = new User();
|
||||
fakeClock = sinon.useFakeTimers(MYSTERY_AWARD_UNIX_TIME);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fakeClock.restore();
|
||||
});
|
||||
|
||||
it('succeeds', async () => {
|
||||
|
|
@ -19,6 +28,12 @@ describe('payments/index', () => {
|
|||
await api.createSubscription(data);
|
||||
expect(user.purchased.plan.planId).to.exist;
|
||||
});
|
||||
|
||||
it('awards mystery items', async () => {
|
||||
data = { user, sub: { key: 'basic_3mo' } };
|
||||
await api.createSubscription(data);
|
||||
expect(user.purchased.plan.mysteryItems.length).to.eql(MYSTERY_AWARD_COUNT);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#cancelSubscription', () => {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function revealMysteryItems (user) {
|
|||
moment().isAfter(shared.content.mystery[item.mystery].start) &&
|
||||
moment().isBefore(shared.content.mystery[item.mystery].end) &&
|
||||
!user.items.gear.owned[item.key] &&
|
||||
user.purchased.plan.mysteryItems.indexOf(item.key) !== -1
|
||||
user.purchased.plan.mysteryItems.indexOf(item.key) === -1
|
||||
) {
|
||||
user.purchased.plan.mysteryItems.push(item.key);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue