mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
Pull out animal content into separate files (#7989)
* Pull out animal content into separate files * Correct variable names * Add tests for stable, eggs, and hatching potions content * Add content test back into npm test
This commit is contained in:
33
test/content/eggs.test.js
Normal file
33
test/content/eggs.test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
each,
|
||||
} from 'lodash';
|
||||
import {
|
||||
expectValidTranslationString,
|
||||
} from '../helpers/content.helper';
|
||||
|
||||
import eggs from '../../common/script/content/eggs';
|
||||
|
||||
describe('eggs', () => {
|
||||
describe('all', () => {
|
||||
it('is a combination of drop and quest eggs', () => {
|
||||
let dropNumber = Object.keys(eggs.drops).length;
|
||||
let questNumber = Object.keys(eggs.quests).length;
|
||||
let allNumber = Object.keys(eggs.all).length;
|
||||
|
||||
expect(allNumber).to.be.greaterThan(0);
|
||||
expect(allNumber).to.equal(dropNumber + questNumber);
|
||||
});
|
||||
|
||||
it('contains basic information about each egg', () => {
|
||||
each(eggs.all, (egg, key) => {
|
||||
expectValidTranslationString(egg.text);
|
||||
expectValidTranslationString(egg.adjective);
|
||||
expectValidTranslationString(egg.mountText);
|
||||
expectValidTranslationString(egg.notes);
|
||||
expect(egg.canBuy).to.be.a('function');
|
||||
expect(egg.value).to.be.a('number');
|
||||
expect(egg.key).to.equal(key);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
31
test/content/hatching-potions.test.js
Normal file
31
test/content/hatching-potions.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import {
|
||||
each,
|
||||
} from 'lodash';
|
||||
import {
|
||||
expectValidTranslationString,
|
||||
} from '../helpers/content.helper';
|
||||
|
||||
import hatchingPotions from '../../common/script/content/hatching-potions';
|
||||
|
||||
describe('hatchingPotions', () => {
|
||||
describe('all', () => {
|
||||
it('is a combination of drop and premium potions', () => {
|
||||
let dropNumber = Object.keys(hatchingPotions.drops).length;
|
||||
let premiumNumber = Object.keys(hatchingPotions.premium).length;
|
||||
let allNumber = Object.keys(hatchingPotions.all).length;
|
||||
|
||||
expect(allNumber).to.be.greaterThan(0);
|
||||
expect(allNumber).to.equal(dropNumber + premiumNumber);
|
||||
});
|
||||
|
||||
it('contains basic information about each potion', () => {
|
||||
each(hatchingPotions.all, (potion, key) => {
|
||||
expectValidTranslationString(potion.text);
|
||||
expectValidTranslationString(potion.notes);
|
||||
expect(potion.canBuy).to.be.a('function');
|
||||
expect(potion.value).to.be.a('number');
|
||||
expect(potion.key).to.equal(key);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
145
test/content/stable.test.js
Normal file
145
test/content/stable.test.js
Normal file
@@ -0,0 +1,145 @@
|
||||
import {
|
||||
each,
|
||||
} from 'lodash';
|
||||
import {
|
||||
expectValidTranslationString,
|
||||
} from '../helpers/content.helper';
|
||||
import t from '../../common/script/content/translation';
|
||||
|
||||
import stable from '../../common/script/content/stable';
|
||||
import eggs from '../../common/script/content/eggs';
|
||||
import potions from '../../common/script/content/hatching-potions';
|
||||
|
||||
describe('stable', () => {
|
||||
describe('dropPets', () => {
|
||||
it('contains a pet for each drop potion * each drop egg', () => {
|
||||
let numberOfDropPotions = Object.keys(potions.drops).length;
|
||||
let numberOfDropEggs = Object.keys(eggs.drops).length;
|
||||
let numberOfDropPets = Object.keys(stable.dropPets).length;
|
||||
let expectedTotal = numberOfDropPotions * numberOfDropEggs;
|
||||
|
||||
expect(numberOfDropPets).to.be.greaterThan(0);
|
||||
expect(numberOfDropPets).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('questPets', () => {
|
||||
it('contains a pet for each drop potion * each quest egg', () => {
|
||||
let numberOfDropPotions = Object.keys(potions.drops).length;
|
||||
let numberOfQuestEggs = Object.keys(eggs.quests).length;
|
||||
let numberOfQuestPets = Object.keys(stable.questPets).length;
|
||||
let expectedTotal = numberOfDropPotions * numberOfQuestEggs;
|
||||
|
||||
expect(numberOfQuestPets).to.be.greaterThan(0);
|
||||
expect(numberOfQuestPets).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('premiumPets', () => {
|
||||
it('contains a pet for each premium potion * each drop egg', () => {
|
||||
let numberOfPremiumPotions = Object.keys(potions.premium).length;
|
||||
let numberOfDropEggs = Object.keys(eggs.drops).length;
|
||||
let numberOfPremiumPets = Object.keys(stable.premiumPets).length;
|
||||
let expectedTotal = numberOfPremiumPotions * numberOfDropEggs;
|
||||
|
||||
expect(numberOfPremiumPets).to.be.greaterThan(0);
|
||||
expect(numberOfPremiumPets).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('specialPets', () => {
|
||||
it('each value is a valid translation string', () => {
|
||||
each(stable.specialPets, (pet) => {
|
||||
let string = t(pet);
|
||||
expectValidTranslationString(string);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('dropMounts', () => {
|
||||
it('contains a mount for each drop potion * each drop egg', () => {
|
||||
let numberOfDropPotions = Object.keys(potions.drops).length;
|
||||
let numberOfDropEggs = Object.keys(eggs.drops).length;
|
||||
let numberOfDropMounts = Object.keys(stable.dropMounts).length;
|
||||
let expectedTotal = numberOfDropPotions * numberOfDropEggs;
|
||||
|
||||
expect(numberOfDropMounts).to.be.greaterThan(0);
|
||||
expect(numberOfDropMounts).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('questMounts', () => {
|
||||
it('contains a mount for each drop potion * each quest egg', () => {
|
||||
let numberOfDropPotions = Object.keys(potions.drops).length;
|
||||
let numberOfQuestEggs = Object.keys(eggs.quests).length;
|
||||
let numberOfQuestMounts = Object.keys(stable.questMounts).length;
|
||||
let expectedTotal = numberOfDropPotions * numberOfQuestEggs;
|
||||
|
||||
expect(numberOfQuestMounts).to.be.greaterThan(0);
|
||||
expect(numberOfQuestMounts).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('premiumMounts', () => {
|
||||
it('contains a mount for each premium potion * each drop egg', () => {
|
||||
let numberOfPremiumPotions = Object.keys(potions.premium).length;
|
||||
let numberOfDropEggs = Object.keys(eggs.drops).length;
|
||||
let numberOfPremiumMounts = Object.keys(stable.premiumMounts).length;
|
||||
let expectedTotal = numberOfPremiumPotions * numberOfDropEggs;
|
||||
|
||||
expect(numberOfPremiumMounts).to.be.greaterThan(0);
|
||||
expect(numberOfPremiumMounts).to.equal(expectedTotal);
|
||||
});
|
||||
});
|
||||
|
||||
describe('specialMounts', () => {
|
||||
it('each value is a valid translation string', () => {
|
||||
each(stable.specialMounts, (mount) => {
|
||||
let string = t(mount);
|
||||
expectValidTranslationString(string);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('petInfo', () => {
|
||||
it('contains an entry for all pets', () => {
|
||||
let dropNumber = Object.keys(stable.dropPets).length;
|
||||
let questNumber = Object.keys(stable.questPets).length;
|
||||
let specialNumber = Object.keys(stable.specialPets).length;
|
||||
let premiumNumber = Object.keys(stable.premiumPets).length;
|
||||
let allNumber = Object.keys(stable.petInfo).length;
|
||||
|
||||
expect(allNumber).to.be.greaterThan(0);
|
||||
expect(allNumber).to.equal(dropNumber + questNumber + specialNumber + premiumNumber);
|
||||
});
|
||||
|
||||
it('contains basic information about each pet', () => {
|
||||
each(stable.petInfo, (pet, key) => {
|
||||
expectValidTranslationString(pet.text);
|
||||
expect(pet.type).to.be.a('string');
|
||||
expect(pet.key).to.equal(key);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('mountInfo', () => {
|
||||
it('contains an entry for all mounts', () => {
|
||||
let dropNumber = Object.keys(stable.dropMounts).length;
|
||||
let questNumber = Object.keys(stable.questMounts).length;
|
||||
let specialNumber = Object.keys(stable.specialMounts).length;
|
||||
let premiumNumber = Object.keys(stable.premiumMounts).length;
|
||||
let allNumber = Object.keys(stable.mountInfo).length;
|
||||
|
||||
expect(allNumber).to.be.greaterThan(0);
|
||||
expect(allNumber).to.equal(dropNumber + questNumber + specialNumber + premiumNumber);
|
||||
});
|
||||
|
||||
it('contains basic information about each mount', () => {
|
||||
each(stable.mountInfo, (mount, key) => {
|
||||
expectValidTranslationString(mount.text);
|
||||
expect(mount.type).to.be.a('string');
|
||||
expect(mount.key).to.equal(key);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user