habitica/test/common/count.js

210 lines
5.8 KiB
JavaScript
Raw Permalink Normal View History

2015-11-20 02:27:39 +00:00
/* eslint-disable camelcase */
2019-10-15 13:32:53 +00:00
import * as count from '../../website/common/script/count';
2015-11-20 02:27:39 +00:00
describe('count', () => {
describe('beastMasterProgress', () => {
it('returns 0 if no pets', () => {
2019-10-08 18:45:38 +00:00
const pets = {};
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(0);
});
2015-11-20 02:27:39 +00:00
it('counts drop pets', () => {
2019-10-08 18:45:38 +00:00
const pets = { 'Dragon-Red': 1, 'Wolf-Base': 2 };
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(2);
});
2015-11-20 02:27:39 +00:00
it('does not count quest pets', () => {
2019-10-08 18:45:38 +00:00
const pets = { 'Dragon-Red': 1, 'Gryphon-Base': 1 };
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('does not count pets hatched with premium potions', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Spooky': 5,
'Dragon-Spooky': 5,
'FlyingPig-Base': 5,
};
2019-10-08 18:45:38 +00:00
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
2015-09-21 21:12:23 +00:00
expect(beastMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('does not count special pets', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Base': 2,
'Wolf-Veteran': 1,
'Wolf-Cerberus': 1,
'Dragon-Hydra': 1,
};
2019-10-08 18:45:38 +00:00
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('counts drop pets that have been raised to a mount', () => {
2019-10-08 18:45:38 +00:00
const raisedToMount = -1;
const pets = { 'Dragon-Red': 1, 'Wolf-Base': raisedToMount };
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(2);
});
2015-11-20 02:27:39 +00:00
it('does not counts drop pets that have been released', () => {
2019-10-08 18:45:38 +00:00
const releasedPet = 0;
const pets = { 'Dragon-Red': 1, 'Wolf-Base': releasedPet };
const beastMasterTotal = count.beastMasterProgress(pets);
2015-11-20 02:27:39 +00:00
expect(beastMasterTotal).to.eql(1);
});
});
2015-11-20 02:27:39 +00:00
describe('mountMasterProgress', () => {
it('returns 0 if no mounts', () => {
2019-10-08 18:45:38 +00:00
const mounts = {};
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
expect(mountMasterTotal).to.eql(0);
});
2015-11-20 02:27:39 +00:00
it('counts drop mounts', () => {
2019-10-08 18:45:38 +00:00
const mounts = { 'Dragon-Red': true, 'Wolf-Base': true };
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
expect(mountMasterTotal).to.eql(2);
});
2015-11-20 02:27:39 +00:00
it('does not count premium mounts', () => {
2019-10-08 18:45:38 +00:00
const mounts = {
2015-11-20 02:27:39 +00:00
'Dragon-Red': true,
'FlyingPig-Spooky': true,
};
2019-10-08 18:45:38 +00:00
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
2015-09-21 21:12:23 +00:00
expect(mountMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('does not count quest mounts', () => {
2019-10-08 18:45:38 +00:00
const mounts = { 'Dragon-Red': true, 'Gryphon-Base': true };
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
expect(mountMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('does not count special mounts', () => {
2019-10-08 18:45:38 +00:00
const mounts = { 'Wolf-Base': true, 'BearCub-Polar': true };
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
expect(mountMasterTotal).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('only counts drop mounts that are currently owned', () => {
2019-10-08 18:45:38 +00:00
const notCurrentlyOwned = false;
const mounts = { 'Dragon-Red': true, 'Wolf-Base': notCurrentlyOwned };
const mountMasterTotal = count.mountMasterProgress(mounts);
2015-11-20 02:27:39 +00:00
expect(mountMasterTotal).to.eql(1);
});
});
2015-11-20 02:27:39 +00:00
describe('remainingGearInSet', () => {
it('counts remaining gear based on set', () => {
2019-10-08 18:45:38 +00:00
const gear = {
2015-11-20 02:27:39 +00:00
weapon_wizard_0: true,
weapon_wizard_1: true,
weapon_warrior_0: true,
weapon_warrior_1: true,
weapon_armor_0: true,
weapon_armor_1: true,
};
2019-10-08 18:45:38 +00:00
const armoireCount = count.remainingGearInSet(gear, 'warrior');
2015-11-20 02:27:39 +00:00
expect(armoireCount).to.eql(20);
});
2015-11-20 02:27:39 +00:00
it.skip('includes previously owned items in count (https: //github.com/HabitRPG/habitrpg/issues/5624#issuecomment-124018717)', () => {
2019-10-08 18:45:38 +00:00
const gear = {
2015-11-20 02:27:39 +00:00
weapon_warrior_0: false,
weapon_warrior_1: false,
weapon_armor_0: true,
weapon_armor_1: true,
};
2019-10-08 18:45:38 +00:00
const armoireCount = count.remainingGearInSet(gear, 'warrior');
2015-11-20 02:27:39 +00:00
expect(armoireCount).to.eql(20);
});
});
2015-11-20 02:27:39 +00:00
describe('dropPetsCurrentlyOwned', () => {
it('counts drop pets owned', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Base': 2,
'Wolf-Red': 4,
};
2019-10-08 18:45:38 +00:00
const dropPets = count.dropPetsCurrentlyOwned(pets);
2015-11-20 02:27:39 +00:00
expect(dropPets).to.eql(2);
});
2015-11-20 02:27:39 +00:00
it('does not count pets that have been raised to mounts', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Base': -1,
'Wolf-Red': 4,
'Wolf-Veteran': 1,
'Gryphon-Base': 1,
};
2019-10-08 18:45:38 +00:00
const dropPets = count.dropPetsCurrentlyOwned(pets);
2015-11-20 02:27:39 +00:00
expect(dropPets).to.eql(1);
});
2015-11-20 02:27:39 +00:00
it('does not count quest pets', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Base': 2,
'Wolf-Red': 4,
'Gryphon-Base': 1,
};
2019-10-08 18:45:38 +00:00
const dropPets = count.dropPetsCurrentlyOwned(pets);
2015-11-20 02:27:39 +00:00
expect(dropPets).to.eql(2);
});
2015-11-20 02:27:39 +00:00
it('does not count special pets', () => {
2019-10-08 18:45:38 +00:00
const pets = {
2015-11-20 02:27:39 +00:00
'Wolf-Base': 2,
'Wolf-Red': 4,
'Wolf-Veteran': 1,
};
2019-10-08 18:45:38 +00:00
const dropPets = count.dropPetsCurrentlyOwned(pets);
2015-11-20 02:27:39 +00:00
expect(dropPets).to.eql(2);
});
});
2015-11-20 02:27:39 +00:00
describe('questsOfCategory', () => {
it('counts user quest scrolls of a particular category', () => {
2019-10-08 18:45:38 +00:00
const quests = {
2015-11-20 02:27:39 +00:00
atom1: 2,
whale: 4,
kraken: 2,
sheep: 1,
goldenknight2: 1,
};
2019-10-08 18:45:38 +00:00
const petQuestCount = count.questsOfCategory(quests, 'pet');
const unlockableQuestCount = count.questsOfCategory(quests, 'unlockable');
const goldQuestCount = count.questsOfCategory(quests, 'gold');
2015-11-20 02:27:39 +00:00
expect(petQuestCount).to.eql(3);
expect(unlockableQuestCount).to.eql(2);
expect(goldQuestCount).to.eql(0);
});
});
});