mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
* move remaining files frm /common/script/public to website/public * remove localstorage * add back noscript template and put all javascript in the footer * fixes client side tests * remove double quotes where possible * simplify jade code and add tests for buildManifest * loading page with logo and spinner * better loading screen in landscape mode * icon on top of text logo * wip: user.notifications * notifications: simpler and working code * finish implementing notifications * correct loading screen css and re-inline images * add tests for user notifications * split User model in multiple files * remove old comment about missing .catch() * correctly setup hooks and methods for User model. Cleanup localstorage * include UserNotificationsService in static page js and split loading-screen css in its own file * add cron notification and misc fixes * remove console.log * fix tests * fix multiple notifications
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
import {
|
|
generateUser,
|
|
generateDaily,
|
|
generateReward,
|
|
translate as t,
|
|
} from '../../../../helpers/api-integration/v3';
|
|
|
|
describe('POST /user/rebirth', () => {
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
it('returns an error when user balance is too low', async () => {
|
|
await expect(user.post('/user/rebirth'))
|
|
.to.eventually.be.rejected.and.to.eql({
|
|
code: 401,
|
|
error: 'NotAuthorized',
|
|
message: t('notEnoughGems'),
|
|
});
|
|
});
|
|
|
|
// More tests in common code unit tests
|
|
|
|
it('resets user\'s tasks', async () => {
|
|
await user.update({
|
|
balance: 2,
|
|
});
|
|
|
|
let daily = await generateDaily({
|
|
text: 'test habit',
|
|
type: 'daily',
|
|
value: 1,
|
|
streak: 1,
|
|
userId: user._id,
|
|
});
|
|
|
|
let reward = await generateReward({
|
|
text: 'test reward',
|
|
type: 'reward',
|
|
value: 1,
|
|
userId: user._id,
|
|
});
|
|
|
|
let response = await user.post('/user/rebirth');
|
|
await user.sync();
|
|
|
|
expect(user.notifications.length).to.equal(1);
|
|
expect(user.notifications[0].type).to.equal('REBIRTH_ACHIEVEMENT');
|
|
|
|
let updatedDaily = await user.get(`/tasks/${daily._id}`);
|
|
let updatedReward = await user.get(`/tasks/${reward._id}`);
|
|
|
|
expect(response.message).to.equal(t('rebirthComplete'));
|
|
expect(updatedDaily.streak).to.equal(0);
|
|
expect(updatedDaily.value).to.equal(0);
|
|
expect(updatedReward.value).to.equal(1);
|
|
});
|
|
});
|