mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
41 lines
1013 B
JavaScript
41 lines
1013 B
JavaScript
import {
|
|
generateUser,
|
|
translate as t,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
import shared from '../../../../../common/script';
|
|
|
|
let content = shared.content;
|
|
|
|
describe('POST /user/buy-quest/:key', () => {
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
// More tests in common code unit tests
|
|
|
|
it('returns an error if the quest is not found', async () => {
|
|
await expect(user.post(`/user/buy-quest/notExisting`))
|
|
.to.eventually.be.rejected.and.eql({
|
|
code: 404,
|
|
error: 'NotFound',
|
|
message: t('questNotFound', {key: 'notExisting'}),
|
|
});
|
|
});
|
|
|
|
it('buys a quest', async () => {
|
|
let key = 'dilatoryDistress1';
|
|
let item = content.quests[key];
|
|
|
|
await user.update({'stats.gp': 250});
|
|
let res = await user.post(`/user/buy-quest/${key}`);
|
|
await user.sync();
|
|
|
|
expect(res.data).to.eql(user.items.quests);
|
|
expect(res.message).to.equal(t('messageBought', {
|
|
itemText: item.text(),
|
|
}));
|
|
});
|
|
});
|