UNPKG

modaq

Version:

Quiz Bowl Reader using TypeScript, React, and MobX

58 lines 2.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); require("src/state/Cycle"); const TeamState_1 = require("src/state/TeamState"); const GameState_1 = require("src/state/GameState"); const PacketState_1 = require("src/state/PacketState"); const firstTeamPlayer = new TeamState_1.Player("Alice", "A", /* isStarter */ true); const secondTeamPlayer = new TeamState_1.Player("Bob", "B", /* isStarter */ true); const players = [firstTeamPlayer, secondTeamPlayer]; const defaultPacket = new PacketState_1.PacketState(); defaultPacket.setTossups([ new PacketState_1.Tossup("first q", "first a"), new PacketState_1.Tossup("second q", "second a"), new PacketState_1.Tossup("third q", "third a"), new PacketState_1.Tossup("fourth q", "fourth a"), ]); defaultPacket.setBonuses([ new PacketState_1.Bonus("first leadin", [{ question: "first q", answer: "first a", value: 10 }]), new PacketState_1.Bonus("second leadin", [{ question: "second q", answer: "second a", value: 10 }]), new PacketState_1.Bonus("third leadin", [{ question: "third q", answer: "third a", value: 10 }]), new PacketState_1.Bonus("fourth leadin", [{ question: "fourth q", answer: "fourth a", value: 10 }]), ]); describe("GameStateTests", () => { describe("getTossupIndex", () => { it("No thrown out tossups", () => { const game = createDefaultGame(); for (let i = 0; i < game.cycles.length; i++) { chai_1.expect(game.getTossupIndex(i)).to.equal(i); } }); it("One thrown out tossup", () => { const game = createDefaultGame(); const thrownOutTossupCycleIndex = 1; game.cycles[thrownOutTossupCycleIndex].addThrownOutTossup(0); chai_1.expect(game.getTossupIndex(0)).to.equal(0); chai_1.expect(game.getTossupIndex(thrownOutTossupCycleIndex)).to.equal(thrownOutTossupCycleIndex + 1); chai_1.expect(game.getTossupIndex(thrownOutTossupCycleIndex + 1)).to.equal(thrownOutTossupCycleIndex + 2); }); it("Multiple thrown out tossups", () => { const game = createDefaultGame(); const thrownOutTossupCycleIndex = 1; const cycle = game.cycles[thrownOutTossupCycleIndex]; cycle.addThrownOutTossup(0); cycle.addThrownOutTossup(1); chai_1.expect(game.getTossupIndex(0)).to.equal(0); chai_1.expect(game.getTossupIndex(thrownOutTossupCycleIndex)).to.equal(thrownOutTossupCycleIndex + 2); chai_1.expect(game.getTossupIndex(thrownOutTossupCycleIndex + 1)).to.equal(thrownOutTossupCycleIndex + 3); }); }); }); function createDefaultGame() { const game = new GameState_1.GameState(); game.addNewPlayers(players); game.loadPacket(defaultPacket); return game; } //# sourceMappingURL=GetTossupIndexTests.js.map