24 lines
1.3 KiB
JavaScript
24 lines
1.3 KiB
JavaScript
const assert = require("node:assert/strict");
|
|
const calendar = require("../static/calendar.js");
|
|
|
|
const birthdays = {
|
|
spring: { 4: ["Kent", 2], 7: ["Lewis"] }
|
|
};
|
|
|
|
assert.equal(calendar.birthdayOn(birthdays, "spring", 4, 1), null);
|
|
assert.equal(calendar.birthdayOn(birthdays, "spring", 4, 2), "Kent");
|
|
assert.equal(calendar.birthdayOn(birthdays, "spring", 7, 1), "Lewis");
|
|
assert.equal(calendar.birthdayOn(birthdays, "spring", 7, 2), "Lewis");
|
|
assert.equal(calendar.birthdayOn(birthdays, "spring", 8, 1), null);
|
|
|
|
console.log("calendar tests passed");
|
|
|
|
// Parsnip (4 days) planted on Spring 1 is ready on Spring 5.
|
|
assert.deepEqual(calendar.harvestDate({ year: 1, season: "spring", day: 1 }, 4), { year: 1, season: "spring", day: 5 });
|
|
// Corn planted late in Summer finishes in Fall; Winter rolls over into the next year.
|
|
assert.deepEqual(calendar.harvestDate({ year: 1, season: "summer", day: 20 }, 14), { year: 1, season: "fall", day: 6 });
|
|
assert.deepEqual(calendar.harvestDate({ year: 1, season: "winter", day: 28 }, 1), { year: 2, season: "spring", day: 1 });
|
|
assert.equal(calendar.daysBetween({ year: 1, season: "spring", day: 3 }, { year: 1, season: "spring", day: 5 }), 2);
|
|
assert.equal(calendar.daysBetween({ year: 1, season: "fall", day: 2 }, { year: 1, season: "summer", day: 28 }), -2);
|
|
|
|
console.log("harvest date tests passed");
|