mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Squashed commit of the following: commit c3c2c364118a90f893ea7fca0a943ea64299234a Author: Matteo Pagliazzi <matteopagliazzi@gmail.com> Date: Sun May 3 22:36:57 2020 +0200 increase timeout to 100ms to allow a correct route change before reload commit 5fd85345ce4a1d3684ca991db7f666803c899e63 Merge: a73b5c942b33331554d3Author: Matteo Pagliazzi <matteopagliazzi@gmail.com> Date: Sun May 3 22:35:33 2020 +0200 Merge branch 'develop' of https://github.com/PitiTheGrey/habitica into PitiTheGrey-develop commit33331554d3Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Sun May 3 22:14:33 2020 +0200 Order fixed. Rekord after reset commit3374ed29dbAuthor: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Sun May 3 22:01:07 2020 +0200 Return to page then reset commit a73b5c942b577dd357ce76380a0102c6823f66c1 Merge: 888f2c82170887141ec4Author: Matteo Pagliazzi <matteopagliazzi@gmail.com> Date: Sun May 3 21:44:16 2020 +0200 Merge branch 'develop' of https://github.com/PitiTheGrey/habitica into PitiTheGrey-develop commit0887141ec4Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Sun May 3 20:42:50 2020 +0200 Remove 2nd try (sorry) commite5534a7cbaAuthor: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Sun May 3 20:14:49 2020 +0200 removed unnecessary lines of code commit 888f2c8217611d367bee912b63d4cc3f4def59bb Merge:aeba14f2e9e5c5f7f1d0Author: Matteo Pagliazzi <matteopagliazzi@gmail.com> Date: Sun May 3 19:43:02 2020 +0200 Merge branch 'develop' of https://github.com/PitiTheGrey/habitica into PitiTheGrey-develop commite5c5f7f1d0Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Sat May 2 14:54:14 2020 +0200 Page reload after reset button pressed commit1c7385f774Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Tue Apr 28 22:23:59 2020 +0200 Update reset.js commit6a8ad34aa6Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Tue Apr 28 22:15:08 2020 +0200 Update reset.js Resets int, con, per, str to 0 and Points to 1 commitba6de48ee3Author: PitiTheGrey <35431804+PitiTheGrey@users.noreply.github.com> Date: Tue Apr 28 22:10:16 2020 +0200 Update reset.js Test if habitica/Website/common/script/ops/reset.js resets int, con, per, str to 0 and Points to 1.
112 lines
2.4 KiB
JavaScript
112 lines
2.4 KiB
JavaScript
import reset from '../../../website/common/script/ops/reset';
|
|
import i18n from '../../../website/common/script/i18n';
|
|
import {
|
|
generateUser,
|
|
generateDaily,
|
|
generateHabit,
|
|
generateReward,
|
|
generateTodo,
|
|
} from '../../helpers/common.helper';
|
|
|
|
describe('shared.ops.reset', () => {
|
|
let user;
|
|
let tasksToRemove;
|
|
|
|
beforeEach(() => {
|
|
user = generateUser();
|
|
user.balance = 2;
|
|
|
|
const habit = generateHabit();
|
|
const todo = generateTodo();
|
|
const daily = generateDaily();
|
|
const reward = generateReward();
|
|
|
|
user.tasksOrder.habits = [habit._id];
|
|
user.tasksOrder.todos = [todo._id];
|
|
user.tasksOrder.dailys = [daily._id];
|
|
user.tasksOrder.rewards = [reward._id];
|
|
|
|
tasksToRemove = [habit, todo, daily, reward];
|
|
});
|
|
|
|
|
|
it('resets a user', () => {
|
|
const [, message] = reset(user);
|
|
|
|
expect(message).to.equal(i18n.t('resetComplete'));
|
|
});
|
|
|
|
it('resets user\'s health', () => {
|
|
user.stats.hp = 40;
|
|
|
|
reset(user);
|
|
|
|
expect(user.stats.hp).to.equal(50);
|
|
});
|
|
|
|
it('resets user\'s level', () => {
|
|
user.stats.lvl = 2;
|
|
|
|
reset(user);
|
|
|
|
expect(user.stats.lvl).to.equal(1);
|
|
});
|
|
|
|
it('resets user\'s stat points (str, con, int, per, points)', () => {
|
|
user.stats.str = 2;
|
|
user.stats.con = 2;
|
|
user.stats.int = 2;
|
|
user.stats.per = 2;
|
|
user.stats.points = 2;
|
|
|
|
reset(user);
|
|
|
|
expect(user.stats.str).to.equal(0);
|
|
expect(user.stats.con).to.equal(0);
|
|
expect(user.stats.int).to.equal(0);
|
|
expect(user.stats.per).to.equal(0);
|
|
expect(user.stats.points).to.equal(1);
|
|
});
|
|
|
|
it('resets user\'s gold', () => {
|
|
user.stats.gp = 20;
|
|
|
|
reset(user);
|
|
|
|
expect(user.stats.gp).to.equal(0);
|
|
});
|
|
|
|
it('resets user\'s exp', () => {
|
|
user.stats.exp = 20;
|
|
|
|
reset(user);
|
|
|
|
expect(user.stats.exp).to.equal(0);
|
|
});
|
|
|
|
it('resets user\'s tasksOrder', () => {
|
|
reset(user, tasksToRemove);
|
|
|
|
expect(user.tasksOrder.habits).to.be.empty;
|
|
expect(user.tasksOrder.todos).to.be.empty;
|
|
expect(user.tasksOrder.dailys).to.be.empty;
|
|
expect(user.tasksOrder.rewards).to.be.empty;
|
|
});
|
|
|
|
it('keeps automaticAllocation false', () => {
|
|
user.preferences.automaticAllocation = false;
|
|
|
|
reset(user);
|
|
|
|
expect(user.preferences.automaticAllocation).to.be.false;
|
|
});
|
|
|
|
it('sets automaticAllocation to false when true', () => {
|
|
user.preferences.automaticAllocation = true;
|
|
|
|
reset(user);
|
|
|
|
expect(user.preferences.automaticAllocation).to.be.false;
|
|
});
|
|
});
|