Files
habitica/test/common/ops/openMysteryItem.js
Sabe Jones fcc14520c5 Don't $watch drops (#7547)
* WIP(drops): get drops out of _tmp

* fix(notifications): no watch for drops/mystery

* fix(ops): only two response values

* fix(test): update op expectation
Also update API docs for modified route.

* fix(lint): remove trailing space

* fix(test): update integration check
2016-05-31 14:56:33 -05:00

40 lines
1.1 KiB
JavaScript

import openMysteryItem from '../../../common/script/ops/openMysteryItem';
import {
generateUser,
} from '../../helpers/common.helper';
import {
BadRequest,
} from '../../../common/script/libs/errors';
import content from '../../../common/script/content/index';
import i18n from '../../../common/script/i18n';
describe('shared.ops.openMysteryItem', () => {
let user;
beforeEach(() => {
user = generateUser();
});
it('returns error when item key is empty', (done) => {
try {
openMysteryItem(user);
} catch (err) {
expect(err).to.be.an.instanceof(BadRequest);
expect(err.message).to.equal(i18n.t('mysteryItemIsEmpty'));
done();
}
});
it('opens mystery item', () => {
let mysteryItemKey = 'eyewear_special_summerRogue';
user.purchased.plan.mysteryItems = [mysteryItemKey];
let [data, message] = openMysteryItem(user);
expect(user.items.gear.owned[mysteryItemKey]).to.be.true;
expect(message).to.equal(i18n.t('mysteryItemOpened'));
expect(data).to.eql(content.gear.flat[mysteryItemKey]);
});
});