stardew-tracker/tests/test_availability.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

const assert = require("node:assert/strict");
const availability = require("../static/availability.js");
const walleye = {
id: "fish-walleye",
meta: "River/Lake · 12pm–2am · rain",
seasons: ["fall"]
};
const fallWindow = availability.classify(walleye, {
checked: false,
chooseGroupComplete: false,
season: "fall"
});
assert.equal(fallWindow.needed, true);
assert.equal(fallWindow.availableNow, true);
assert.equal(fallWindow.seasonExclusive, true);
assert.equal(fallWindow.weather, "Rain");
assert.equal(availability.matchesFilter(fallWindow, "now"), true);
assert.equal(availability.matchesFilter(fallWindow, "exclusive"), true);
assert.equal(availability.matchesFilter(fallWindow, "weather"), true);
const springWalleye = availability.classify(walleye, {
checked: false,
chooseGroupComplete: false,
season: "spring"
});
assert.equal(springWalleye.availableNow, false);
assert.equal(availability.matchesFilter(springWalleye, "now"), false);
assert.equal(availability.matchesFilter(springWalleye, "weather"), false);
const optionalChoice = availability.classify({
id: "crab-clam",
meta: "Ocean crab pot",
seasons: []
}, {
checked: false,
chooseGroupComplete: true,
season: "spring"
});
assert.equal(optionalChoice.needed, false);
assert.equal(availability.matchesFilter(optionalChoice, "open"), false);
assert.equal(availability.matchesFilter(optionalChoice, "now"), false);
console.log("availability tests passed");