From f073129f38396296c7886f577429246afe9094d0 Mon Sep 17 00:00:00 2001 From: Adrian Wannenmacher Date: Sun, 15 Feb 2026 04:41:40 +0100 Subject: [PATCH] test that invalid constructor forms throw --- models/game.test.js | 6 ++++++ models/round.test.js | 6 ++++++ models/round_result.test.js | 6 ++++++ models/session.test.js | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/models/game.test.js b/models/game.test.js index 74a27cc..ec19eda 100644 --- a/models/game.test.js +++ b/models/game.test.js @@ -23,6 +23,12 @@ export default function() { ); }); + QUnit.test("invalid constructor", function(assert) { + assert.throws( + function() {new Game("nope", "absolutely", "not"); }, + new TypeError("unknown form of Game constructor")); + }); + QUnit.test("low goal", function(assert) { assert.throws( function() { new Game(0); }, diff --git a/models/round.test.js b/models/round.test.js index df791c2..49387c5 100644 --- a/models/round.test.js +++ b/models/round.test.js @@ -13,6 +13,12 @@ export default function() { assert.true(round.canRaise(Team.They), "they initially can raise"); }); + QUnit.test("invalid constructor", function(assert) { + assert.throws( + function() {new Round("nope", "absolutely", "not"); }, + new TypeError("unknown form of Round constructor")); + }); + QUnit.test("immediate victory", function(assert) { let round = new Round(); round.winner = Team.We; diff --git a/models/round_result.test.js b/models/round_result.test.js index 584fcc6..80c10dc 100644 --- a/models/round_result.test.js +++ b/models/round_result.test.js @@ -11,6 +11,12 @@ export default function() { assert.strictEqual(rr.winner, Team.We, "correct winner"); }); + QUnit.test("invalid constructor", function(assert) { + assert.throws( + function() {new RoundResult("nope", "absolutely", "not"); }, + new TypeError("unknown form of RoundResult constructor")); + }); + QUnit.test("toStruct", function(assert) { let rr = new RoundResult(2, Team.They); let struct = rr.toStruct(); diff --git a/models/session.test.js b/models/session.test.js index 3a87209..2493247 100644 --- a/models/session.test.js +++ b/models/session.test.js @@ -19,6 +19,12 @@ export default function() { assert.strictEqual(session.theirTeam, "", "their team name"); }); + QUnit.test("invalid constructor", function(assert) { + assert.throws( + function() {new Session("nope", "absolutely", "not"); }, + new TypeError("unknown form of Session constructor")); + }); + QUnit.test("set goal", function(assert) { let session = new Session(); assert.strictEqual(session.goal, 11, "initial goal");