Improve test coverage

This commit is contained in:
Phillip Thelen
2024-06-10 14:44:21 +02:00
parent 3333f8f0f5
commit fc63c906dd
5 changed files with 69 additions and 3 deletions

View File

@@ -0,0 +1,66 @@
import find from 'lodash/find';
import {
ARMOIRE_RELEASE_DATES,
EGGS_RELEASE_DATES,
HATCHING_POTIONS_RELEASE_DATES,
} from '../../website/common/script/content/constants/releaseDates';
import content from '../../website/common/script/content';
describe('releaseDates', () => {
describe('armoire', () => {
it('should only contain valid armoire names', () => {
Object.keys(ARMOIRE_RELEASE_DATES).forEach(key => {
expect(find(content.gear.flat, { set: key }), `${key} is not a valid armoire set`).to.exist;
});
});
it('should contain a valid year and month', () => {
Object.keys(ARMOIRE_RELEASE_DATES).forEach(key => {
const date = ARMOIRE_RELEASE_DATES[key];
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
expect(date.year).to.be.at.least(2023);
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
expect(date.month).to.be.within(1, 12);
expect(date.day).to.not.exist;
});
});
});
describe('eggs', () => {
it('should only contain valid egg names', () => {
Object.keys(EGGS_RELEASE_DATES).forEach(key => {
expect(content.eggs[key], `${key} is not a valid egg name`).to.exist;
});
});
it('should contain a valid year, month and date', () => {
Object.keys(EGGS_RELEASE_DATES).forEach(key => {
const date = EGGS_RELEASE_DATES[key];
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
expect(date.year).to.be.at.least(2024);
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
expect(date.month).to.be.within(1, 12);
expect(date.day, `${key} day is not a valid day`).to.be.a('number');
});
});
});
describe('hatchingPotions', () => {
it('should only contain valid potion names', () => {
Object.keys(HATCHING_POTIONS_RELEASE_DATES).forEach(key => {
expect(content.hatchingPotions[key], `${key} is not a valid potion name`).to.exist;
});
});
it('should contain a valid year, month and date', () => {
Object.keys(HATCHING_POTIONS_RELEASE_DATES).forEach(key => {
const date = HATCHING_POTIONS_RELEASE_DATES[key];
expect(date.year, `${key} year is not a valid year`).to.be.a('number');
expect(date.year).to.be.at.least(2024);
expect(date.month, `${key} month is not a valid month`).to.be.a('number');
expect(date.month).to.be.within(1, 12);
expect(date.day, `${key} day is not a valid day`).to.be.a('number');
});
});
});
});

View File

@@ -3,7 +3,7 @@ import each from 'lodash/each';
import assign from 'lodash/assign';
import t from './translation';
import { filterReleased } from './is_released';
import { EGGS_RELEASE_DATES } from './constants/release_dates';
import { EGGS_RELEASE_DATES } from './constants/releaseDates';
import datedMemoize from '../fns/datedMemoize';
function applyEggDefaults (set, config) {

View File

@@ -7,7 +7,7 @@ import { ownsItem } from '../gear-helper';
import { ATTRIBUTES } from '../../../constants';
import t from '../../translation';
import memoize from '../../../fns/datedMemoize';
import { ARMOIRE_RELEASE_DATES as releaseDates } from '../../constants/release_dates';
import { ARMOIRE_RELEASE_DATES as releaseDates } from '../../constants/releaseDates';
import { buildReleaseDate } from '../../is_released';
const armor = {

View File

@@ -4,7 +4,7 @@ import { assign } from 'lodash';
import t from './translation';
import datedMemoize from '../fns/datedMemoize';
import { filterReleased } from './is_released';
import { HATCHING_POTIONS_RELEASE_DATES } from './constants/release_dates';
import { HATCHING_POTIONS_RELEASE_DATES } from './constants/releaseDates';
function hasQuestAchievementFunction (key) {
return user => user.achievements.quests && user.achievements.quests[key] > 0;