mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
* Fix: moved debuffPotions from vue component - Move logic of choosing proper debuf potion from vue component to website commons - introduce new function to get debuffSpellItems * Fix: move debuffPotions to server * Refactoring: move setting of debuff potion to func * Fix: sanity * Refactoring & Tests: - Create test case for get and set DebuffPotionItems functions - Fix setDebuffPotionItems function to not create duplicated debuff items - Make debuff potion type of items unpinnable - Move list of debuffs to constant to reuse it in tests and functions * Fix: typo in test describe * Fix: translation of unpin * Fix: setDebuffPotionItems on cron buffs reset * Fix: use full path for debuff potions
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
|
|
import {
|
|
generateUser,
|
|
} from '../../helpers/common.helper';
|
|
|
|
import setDebuffPotionItems from '../../../website/common/script/libs/setDebuffPotionItems';
|
|
|
|
describe('setDebuffPotionItems', () => {
|
|
let user;
|
|
|
|
beforeEach(() => {
|
|
user = generateUser();
|
|
});
|
|
|
|
it('Should push the debuff item to pinned items of user', () => {
|
|
user.stats.buffs.spookySparkles = true;
|
|
const previousPinnedItemsLength = user.pinnedItems.length;
|
|
|
|
let result = setDebuffPotionItems(user);
|
|
|
|
expect(result.pinnedItems.length).to.be.greaterThan(previousPinnedItemsLength);
|
|
});
|
|
|
|
it('Shouldn\'t create duplicate of already added debuff potion', () => {
|
|
user.stats.buffs.spookySparkles = true;
|
|
|
|
const firstSetResult = [...setDebuffPotionItems(user).pinnedItems];
|
|
const secondSetResult = [...setDebuffPotionItems(user).pinnedItems];
|
|
|
|
|
|
expect(firstSetResult).to.be.deep.equal(secondSetResult);
|
|
});
|
|
|
|
it('Should remove all debuff items from pinnedItems of the user if user have no buffs', () => {
|
|
user.stats.buffs.seafoam = true;
|
|
user.stats.buffs.spookySparkles = true;
|
|
user.stats.buffs.snowball = true;
|
|
user.stats.buffs.shinySeed = true;
|
|
|
|
const firstSetResult = [...setDebuffPotionItems(user).pinnedItems];
|
|
|
|
expect(firstSetResult).to.have.lengthOf(4);
|
|
|
|
user.stats.buffs.seafoam = false;
|
|
user.stats.buffs.spookySparkles = false;
|
|
user.stats.buffs.snowball = false;
|
|
user.stats.buffs.shinySeed = false;
|
|
|
|
const secondSetResult = [...setDebuffPotionItems(user).pinnedItems];
|
|
|
|
expect(secondSetResult).to.have.lengthOf(0);
|
|
});
|
|
});
|