Ask the six optional setup questions after size so each tick can change suggested cards, keeping the answers on the draft and off the published Rule.
This commit is contained in:
1 parent
b4bfa157f8
commit
bdaf1818d9
23 files changed
+399
-82
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TRAIT_KEYS } from "../../lib/create/deckTypes";
|
||||
import {
|
||||
EMPTY_SETUP_TRAITS,
|
||||
hasTickedSetupTrait,
|
||||
setupTraitsFromTickedIds,
|
||||
tickedSetupTraitIds,
|
||||
} from "../../lib/create/setupTraits";
|
||||
|
||||
describe("setupTraits", () => {
|
||||
it("starts with every question off", () => {
|
||||
expect(TRAIT_KEYS.every((key) => EMPTY_SETUP_TRAITS[key] === false)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(hasTickedSetupTrait(undefined)).toBe(false);
|
||||
expect(hasTickedSetupTrait(EMPTY_SETUP_TRAITS)).toBe(false);
|
||||
expect(tickedSetupTraitIds(undefined)).toEqual([]);
|
||||
});
|
||||
|
||||
it("round-trips ticked ids as true or false on every trait", () => {
|
||||
const traits = setupTraitsFromTickedIds(["employer", "records"]);
|
||||
expect(traits).toEqual({
|
||||
network: false,
|
||||
nonvoters: false,
|
||||
employer: true,
|
||||
sponsor: false,
|
||||
records: true,
|
||||
risky: false,
|
||||
});
|
||||
expect(tickedSetupTraitIds(traits)).toEqual(["employer", "records"]);
|
||||
expect(hasTickedSetupTrait(traits)).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores ids that are not setup questions", () => {
|
||||
expect(setupTraitsFromTickedIds(["employer", "police"])).toEqual({
|
||||
...EMPTY_SETUP_TRAITS,
|
||||
employer: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user