support april fools resale in schedule

This commit is contained in:
Phillip Thelen
2024-05-08 17:42:40 +02:00
parent 6ed422cd28
commit a9cefd284a
3 changed files with 32 additions and 29 deletions
+10 -26
View File
@@ -19,7 +19,7 @@ function validateMatcher (matcher, checkedDate) {
expect(matcher.end).to.be.greaterThan(checkedDate);
}
describe('Content Schedule', () => {
describe.only('Content Schedule', () => {
beforeEach(() => {
clearCachedMatchers();
});
@@ -96,58 +96,42 @@ describe('Content Schedule', () => {
it('sets the end date if its in the same month', () => {
const date = new Date('2024-04-03');
const matchers = getAllScheduleMatchingGroups(date);
for (const key in matchers) {
if (matchers[key]) {
validateMatcher(matchers[key], date);
}
}
expect(matchers.backgrounds.end).to.eql(moment('2024-04-07').toDate());
});
it('sets the end date if its in the next day', () => {
const date = new Date('2024-05-06T14:00:00.000Z');
const matchers = getAllScheduleMatchingGroups(date);
for (const key in matchers) {
if (matchers[key]) {
validateMatcher(matchers[key], date);
}
}
expect(matchers.backgrounds.end).to.eql(moment('2024-05-07').toDate());
});
it('sets the end date if its on the release day', () => {
const date = new Date('2024-05-07');
const matchers = getAllScheduleMatchingGroups(date);
for (const key in matchers) {
if (matchers[key]) {
validateMatcher(matchers[key], date);
}
}
expect(matchers.backgrounds.end).to.eql(moment('2024-06-07').toDate());
});
it('sets the end date if its next month', () => {
const date = new Date('2024-05-20T01:00:00.000Z');
const matchers = getAllScheduleMatchingGroups(date);
for (const key in matchers) {
if (matchers[key]) {
validateMatcher(matchers[key], date);
}
}
expect(matchers.backgrounds.end).to.eql(moment('2024-06-07').toDate());
});
it('sets the end date for a gala', () => {
const date = new Date('2024-05-20');
const matchers = getAllScheduleMatchingGroups(date);
for (const key in matchers) {
if (matchers[key]) {
validateMatcher(matchers[key], date);
}
}
expect(matchers.seasonalGear.end).to.eql(moment('2024-06-21').toDate());
});
it('contains content for repeating events', () => {
const date = new Date('2024-04-15');
const matchers = getAllScheduleMatchingGroups(date);
expect(matchers.premiumHatchingPotions).to.exist;
expect(matchers.premiumHatchingPotions.items.length).to.equal(4);
expect(matchers.premiumHatchingPotions.items.indexOf('Garden')).to.not.equal(-1);
expect(matchers.premiumHatchingPotions.items.indexOf('Porcelain')).to.not.equal(-1);
});
describe('only contains valid keys for', () => {
it('pet quests', () => {
const petKeys = Object.keys(QUEST_PETS);
@@ -51,6 +51,26 @@ export const REPEATING_EVENTS = {
end: new Date('1970-03-15T23:59-05:00'),
foodSeason: 'Pie',
},
aprilFoolsResale: {
start: new Date('1970-04-07T08:00-05:00'),
end: new Date('1970-04-30T23:59-05:00'),
content: [
{
type: 'hatchingPotionQuests',
items: [
'virtualpet',
'waffle',
],
},
{
type: 'premiumHatchingPotions',
items: [
'Garden',
'TeaShop',
],
},
],
},
namingDay: {
start: new Date('1970-07-30T08:00-05:00'),
end: new Date('1970-08-01T23:59-05:00'),
@@ -701,7 +701,6 @@ export const GALA_SCHEDULE = {
type: 'seasonalQuests',
items: [
'egg',
'waffle',
],
},
{
@@ -835,11 +834,11 @@ export function assembleScheduledMatchers (date) {
matcher.endMonth = gala.endMonth;
});
items.push(...galaMatchers);
for (const event in getRepeatingEvents(date)) {
getRepeatingEvents(date).forEach(event => {
if (event.content) {
items.push(...event.content);
}
}
});
return items;
}