adventofcode/2022/07/test.js

39 lines
953 B
JavaScript

import { test, expect, describe } from "vitest";
import { expectSolution } from "../01/main.js";
import part1, { puzzleInput, sample, parseInput, cumulative } from "./part1.js";
import part2 from "./part2.js";
describe("part 1", () => {
const expected = { "/": 23352670, "/a": 94269, "/a/e": 584, "/d": 24933642 };
test("parseInput", () => {
const data = parseInput(sample);
expect(data).toEqual(expected);
});
test("cumulative", () => {
expect(cumulative(expected)).toEqual({
"/": 48381165,
"/a": 94853,
"/a/e": 584,
"/d": 24933642,
});
});
test("solution", () => {
expectSolution(part1(puzzleInput)).toEqual(1350966);
});
});
describe("part 2", () => {
test("sample", () => {
expect(part2(sample)).toEqual(24933642);
});
test("solution", () => {
expectSolution(part2(puzzleInput)).toBeLessThan(46647330);
expectSolution(part2(puzzleInput)).toEqual(6296435);
});
});