diff --git a/test/content/food.test.js b/test/content/food.test.js new file mode 100644 index 0000000000..b0f1938f0f --- /dev/null +++ b/test/content/food.test.js @@ -0,0 +1,94 @@ +/* eslint-disable global-require */ +import { + each, +} from 'lodash'; +import { + expectValidTranslationString, +} from '../helpers/content.helper'; +import content from '../../website/common/script/content'; + +describe('food', () => { + let clock; + + afterEach(() => { + if (clock) { + clock.restore(); + } + delete require.cache[require.resolve('../../website/common/script/content')]; + }); + + describe('all', () => { + it('contains basic information about each food item', () => { + each(content.food, (foodItem, key) => { + if (foodItem.key === 'Saddle') { + expectValidTranslationString(foodItem.sellWarningNote); + } else { + expectValidTranslationString(foodItem.textA); + expectValidTranslationString(foodItem.textThe); + expectValidTranslationString(foodItem.target); + } + expectValidTranslationString(foodItem.text); + expectValidTranslationString(foodItem.notes); + expect(foodItem.canBuy).to.be.a('function'); + expect(foodItem.value).to.be.a('number'); + expect(foodItem.key).to.equal(key); + }); + }); + + it('sets canDrop for normal food if there is no food season', () => { + clock = sinon.useFakeTimers(new Date(2024, 5, 8)); + const datedContent = require('../../website/common/script/content').default; + each(datedContent.food, foodItem => { + if (foodItem.key.indexOf('Cake') === -1 && foodItem.key.indexOf('Candy_') === -1 && foodItem.key.indexOf('Pie_') === -1 && foodItem.key !== 'Saddle') { + expect(foodItem.canDrop).to.equal(true); + } else { + expect(foodItem.canDrop).to.equal(false); + } + }); + }); + + it('sets canDrop for candy if it is candy season', () => { + clock = sinon.useFakeTimers(new Date(2024, 9, 31)); + const datedContent = require('../../website/common/script/content').default; + each(datedContent.food, foodItem => { + if (foodItem.key.indexOf('Candy_') !== -1) { + expect(foodItem.canDrop).to.equal(true); + } else { + expect(foodItem.canDrop).to.equal(false); + } + }); + }); + + it('sets canDrop for cake if it is cake season', () => { + clock = sinon.useFakeTimers(new Date(2024, 0, 31)); + const datedContent = require('../../website/common/script/content').default; + each(datedContent.food, foodItem => { + if (foodItem.key.indexOf('Cake_') !== -1) { + expect(foodItem.canDrop).to.equal(true); + } else { + expect(foodItem.canDrop).to.equal(false); + } + }); + }); + + it('sets canDrop for pie if it is pie season', () => { + clock = sinon.useFakeTimers(new Date(2024, 2, 14)); + const datedContent = require('../../website/common/script/content').default; + each(datedContent.food, foodItem => { + if (foodItem.key.indexOf('Pie_') !== -1) { + expect(foodItem.canDrop).to.equal(true); + } else { + expect(foodItem.canDrop).to.equal(false); + } + }); + }); + }); + + it('sets correct values for saddles', () => { + const saddle = content.food.Saddle; + expect(saddle.canBuy).to.be.a('function'); + expect(saddle.value).to.equal(5); + expect(saddle.key).to.equal('Saddle'); + expect(saddle.canDrop).to.equal(false); + }); +}); diff --git a/test/content/schedule.test.js b/test/content/schedule.test.js index 573a3ab8ca..fc6e61b884 100644 --- a/test/content/schedule.test.js +++ b/test/content/schedule.test.js @@ -19,7 +19,7 @@ function validateMatcher (matcher, checkedDate) { expect(matcher.end).to.be.greaterThan(checkedDate); } -describe.only('Content Schedule', () => { +describe('Content Schedule', () => { beforeEach(() => { clearCachedMatchers(); }); diff --git a/website/common/script/content/constants/events.js b/website/common/script/content/constants/events.js index cdccf581ec..8771f87cf9 100644 --- a/website/common/script/content/constants/events.js +++ b/website/common/script/content/constants/events.js @@ -78,7 +78,7 @@ export function getRepeatingEvents (date) { const endDate = eventData.end.replace('1970', momentDate.year()); return momentDate.isBetween(startDate, endDate); - }); + }).map(eventKey => REPEATING_EVENTS[eventKey]); } export const EVENTS = {