adventofcode/2022/09/test.js

41 lines
952 B
JavaScript

import { test, expect, describe } from "vitest";
import Victor from "@a-robu/victor";
const V = (...args) => new Victor(...args);
import { expectSolution } from "../01/main.js";
import part1, { moveOnce, sample, puzzleInput } from "./part1.js";
import part2 from "./part2.js";
describe("part 1", () => {
test( "moveOnce", () => {
let head = V(1,0);
let tail = V(0,0);
moveOnce(head,tail,V(1,0));
expect(tail).toMatchObject({x:1,y:0});
moveOnce(head,tail,V(0,1));
expect(tail).toMatchObject({x:1,y:0});
moveOnce(head,tail,V(0,1));
expect(tail).toMatchObject({x:2,y:1});
} );
test( "sample", () => {
expect(part1(sample)).toEqual(13);
} )
test("solution", () => {
expectSolution(part1(puzzleInput)).toEqual(6030);
});
});
describe("part 2", () => {
test.todo("solution", () => {
expectSolution(part2(puzzleInput)).toEqual("TODO");
});
});