mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
* Re-organize common folder * fix: Correct paths in tests * fix: move new content to proper folder * chore: Move audio folder to assets * Move sprites to sprites assets directory * Move css sprites to assets directory * Split out readmes for common code and sprites * Move images to assets directory * Move destinatin of shared browserified file * remove unused file * move compiled js to client-old * Fix karma tests * fix: Correct paths for sprites
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import openMysteryItem from '../../../website/common/script/ops/openMysteryItem';
|
|
import {
|
|
generateUser,
|
|
} from '../../helpers/common.helper';
|
|
import {
|
|
BadRequest,
|
|
} from '../../../website/common/script/libs/errors';
|
|
import content from '../../../website/common/script/content/index';
|
|
import i18n from '../../../website/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]);
|
|
});
|
|
});
|