mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +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
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import {
|
|
generateUser,
|
|
translate as t,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
import shared from '../../../../../website/common/script';
|
|
|
|
let content = shared.content;
|
|
|
|
describe('POST /user/buy-health-potion', () => {
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser({
|
|
'stats.hp': 40,
|
|
});
|
|
});
|
|
|
|
// More tests in common code unit tests
|
|
|
|
it('returns an error if user does not have enough gold', async () => {
|
|
await expect(user.post('/user/buy-health-potion'))
|
|
.to.eventually.be.rejected.and.eql({
|
|
code: 401,
|
|
error: 'NotAuthorized',
|
|
message: t('messageNotEnoughGold'),
|
|
});
|
|
});
|
|
|
|
it('buys a potion', async () => {
|
|
await user.update({
|
|
'stats.gp': 400,
|
|
});
|
|
|
|
let potion = content.potion;
|
|
let res = await user.post('/user/buy-health-potion');
|
|
await user.sync();
|
|
|
|
expect(user.stats.hp).to.equal(50);
|
|
expect(res.data).to.eql(user.stats);
|
|
expect(res.message).to.equal(t('messageBought', {itemText: potion.text()}));
|
|
});
|
|
});
|