Treat a typed main kind as no kind so recommendations still fall back to size.
A custom kind no longer empties a job of eligible cards, and other catalog kinds stay ranking hints instead of becoming the main kind.
This commit is contained in:
1 parent
dad8661268
commit
f795951443
5 files changed
+116
-16
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { deckData, recommendDeck } from "../../lib/create/deckRecommend";
|
||||
import type { Kind } from "../../lib/create/deckTypes";
|
||||
|
||||
describe("recommendDeck typed main kind", () => {
|
||||
const sizeOnly = {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
};
|
||||
|
||||
it("treats a typed main kind as no kind so eligibility falls back to size", () => {
|
||||
const typed = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "streetMedicCrew" as Kind,
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
const coop = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "workersCoop",
|
||||
});
|
||||
|
||||
expect(typed.fallback).toBe(false);
|
||||
expect(typed.recommended.map((card) => card.id)).toEqual(
|
||||
none.recommended.map((card) => card.id),
|
||||
);
|
||||
expect(
|
||||
typed.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
coop.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps other catalog kinds as ranking hints, not as the main kind", () => {
|
||||
const typedWithOther = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
otherKinds: ["workersCoop"],
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
|
||||
expect(typedWithOther.fallback).toBe(false);
|
||||
expect(new Set(typedWithOther.recommended.map((card) => card.job))).toEqual(
|
||||
new Set(none.recommended.map((card) => card.job)),
|
||||
);
|
||||
expect(
|
||||
typedWithOther.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user