2024-06-10 12:44:21 +00:00
|
|
|
import find from 'lodash/find';
|
2024-06-19 14:33:11 +00:00
|
|
|
import maxBy from 'lodash/maxBy';
|
2024-06-10 12:44:21 +00:00
|
|
|
import {
|
|
|
|
|
ARMOIRE_RELEASE_DATES,
|
|
|
|
|
EGGS_RELEASE_DATES,
|
|
|
|
|
HATCHING_POTIONS_RELEASE_DATES,
|
|
|
|
|
} from '../../website/common/script/content/constants/releaseDates';
|
2024-06-19 14:33:11 +00:00
|
|
|
import armoire from '../../website/common/script/content/gear/sets/armoire';
|
|
|
|
|
import eggs from '../../website/common/script/content/eggs';
|
|
|
|
|
import hatchingPotions from '../../website/common/script/content/hatching-potions';
|
2024-06-10 12:44:21 +00:00
|
|
|
|
|
|
|
|
describe('releaseDates', () => {
|
2024-06-19 14:33:11 +00:00
|
|
|
let clock;
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
if (clock) {
|
|
|
|
|
clock.restore();
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-06-10 12:44:21 +00:00
|
|
|
describe('armoire', () => {
|
|
|
|
|
it('should only contain valid armoire names', () => {
|
2024-06-19 14:33:11 +00:00
|
|
|
const lastReleaseDate = maxBy(Object.values(ARMOIRE_RELEASE_DATES), value => new Date(`${value.year}-${value.month + 1}-20`));
|
|
|
|
|
clock = sinon.useFakeTimers(new Date(`${lastReleaseDate.year}-${lastReleaseDate.month + 1}-20`));
|
2024-06-10 12:44:21 +00:00
|
|
|
Object.keys(ARMOIRE_RELEASE_DATES).forEach(key => {
|
2024-06-19 14:33:11 +00:00
|
|
|
expect(find(armoire.all, { set: key }), `${key} is not a valid armoire set`).to.exist;
|
2024-06-10 12:44:21 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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', () => {
|
2024-06-19 14:33:11 +00:00
|
|
|
const lastReleaseDate = maxBy(Object.values(EGGS_RELEASE_DATES), value => new Date(`${value.year}-${value.month + 1}-${value.day}`));
|
|
|
|
|
clock = sinon.useFakeTimers(new Date(`${lastReleaseDate.year}-${lastReleaseDate.month + 1}-${lastReleaseDate.day}`));
|
2024-06-10 12:44:21 +00:00
|
|
|
Object.keys(EGGS_RELEASE_DATES).forEach(key => {
|
2024-06-19 14:33:11 +00:00
|
|
|
expect(eggs.all[key], `${key} is not a valid egg name`).to.exist;
|
2024-06-10 12:44:21 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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', () => {
|
2024-06-19 14:33:11 +00:00
|
|
|
const lastReleaseDate = maxBy(Object.values(HATCHING_POTIONS_RELEASE_DATES), value => new Date(`${value.year}-${value.month + 1}-${value.day}`));
|
|
|
|
|
clock = sinon.useFakeTimers(new Date(`${lastReleaseDate.year}-${lastReleaseDate.month + 1}-${lastReleaseDate.day}`));
|
2024-06-10 12:44:21 +00:00
|
|
|
Object.keys(HATCHING_POTIONS_RELEASE_DATES).forEach(key => {
|
2024-06-19 14:33:11 +00:00
|
|
|
expect(hatchingPotions.all[key], `${key} is not a valid potion name`).to.exist;
|
2024-06-10 12:44:21 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|