Skip to content

Commit e5c6455

Browse files
committed
fix: error expectation test context
1 parent e4bd03f commit e5c6455

4 files changed

+20
-12
lines changed

day-02-dive.spec.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { commands } from './day-02-dive.input';
33

44
describe('Day 2 - Dive', () => {
55
test('should throw Error for unknown commands', () => {
6-
const measurer = new DiverCommandsInterpreter([['unknown', 1]]);
7-
expect(() => measurer.computeOffsetFromCommands()).toThrowError();
6+
expect(() => {
7+
const measurer = new DiverCommandsInterpreter([['unknown', 1]]);
8+
measurer.computeOffsetFromCommands();
9+
}).toThrowError();
810
});
911
test('should return [0, 0] for no commands', () => {
1012
const measurer = new DiverCommandsInterpreter([]);

day-03-binary-diagnostic.spec.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { binaryNumbers } from './day-03-binary-diagnostic.input';
33

44
describe('Day 3 - Binary Diagnostic', () => {
55
test('should throw Error for empty readings', () => {
6-
const calculator = new DiagnosticReportCalculator([]);
7-
expect(() => calculator.computeEpsilonAndGamma()).toThrowError();
6+
expect(() => {
7+
const calculator = new DiagnosticReportCalculator([]);
8+
calculator.computeEpsilonAndGamma();
9+
}).toThrowError();
810
});
911
test('should throw Error for inconsistent reading lengths', () => {
10-
const calculator = new DiagnosticReportCalculator(['1', '01']);
11-
expect(() => calculator.computeEpsilonAndGamma()).toThrowError();
12+
expect(() => {
13+
const calculator = new DiagnosticReportCalculator(['1', '01']);
14+
calculator.computeEpsilonAndGamma();
15+
}).toThrowError();
1216
});
1317
test('should return 2743844 for puzzle part 1 answer', () => {
1418
const calculator = new DiagnosticReportCalculator(binaryNumbers);

day-04-bingo-squid.spec.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { BingoSolver, NO_WINNING_BOARDS_ERROR } from './day-04-bingo-squid';
1+
import { BingoSolver, NO_BOARDS_PROVIDED_ERROR } from './day-04-bingo-squid';
22
import { boards, drawnNumbers } from './day-04-bingo-squid.input';
33
import { exampleBoards, exampleDrawnNumbers } from './day-04-bingo-squid.example';
44

55
describe('Day 4 - Bingo Squid', () => {
6-
test('should throw NO_WINNING_BOARDS_ERROR for empty boards', () => {
7-
const solver = new BingoSolver([], []);
8-
expect(() => solver.computeWinningBoard()).toThrowError(NO_WINNING_BOARDS_ERROR);
6+
test('should throw NO_BOARDS_PROVIDED_ERROR for empty boards', () => {
7+
expect(() => {
8+
const solver = new BingoSolver([], []);
9+
solver.computeWinningBoard();
10+
}).toThrowError(NO_BOARDS_PROVIDED_ERROR);
911
});
1012
test('should be able to compute winning board score from example input', () => {
1113
const solver = new BingoSolver(exampleBoards, exampleDrawnNumbers);

day-04-bingo-squid.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export const NO_DRAWN_NUMBERS_PROVIDED_ERROR = new Error('There are no drawn numbers');
2-
export const NO_BOARDS_PROVIDED_ERROR = new Error('There are no drawn numbers');
1+
export const NO_DRAWN_NUMBERS_PROVIDED_ERROR = new Error('No drawn numbers provided');
2+
export const NO_BOARDS_PROVIDED_ERROR = new Error('No board numbers provided');
33
export const NO_WINNING_BOARDS_ERROR = new Error('There are no winning boards');
44

55
export interface WinningBoardResult {

0 commit comments

Comments
 (0)