adventofcode/2022/14/test.js

44 lines
917 B
JavaScript

import { test, expect, describe } from "vitest";
import { expectSolution } from "../01/main.js";
import part1, { genCave, sample, puzzleInput } from "./part1.js";
import part2 from "./part2.js";
describe("part 1", () => {
test("readInput", () => {
expect(sample).toEqual([
[
[498, 4],
[498, 6],
[496, 6],
],
[
[503, 4],
[502, 4],
[502, 9],
[494, 9],
],
]);
});
test("genCave", () => {
expect(genCave(sample)).toMatchObject({
4: { 498: "#" },
});
});
test("sample", () => {
expect(part1(sample)).toEqual(24);
});
test("solution", () => {
expectSolution(part1(puzzleInput)).toEqual(832);
});
});
describe.only("part 2", () => {
test("sample", () => {
expect(part2(sample)).toEqual(93);
});
test("solution", () => {
expectSolution(part2(puzzleInput)).toEqual(27601);
});
});