advent22/ui/tests/unit/rectangle.spec.ts

24 lines
561 B
TypeScript
Raw Normal View History

2023-01-21 02:59:46 +00:00
import { Vector2D } from '@/components/rects/rectangles';
import { expect } from "chai";
describe("Vector Tests", () => {
const v = new Vector2D(1, 2);
it("should create a vector", () => {
expect(v.x).to.equal(1);
expect(v.y).to.equal(2);
});
it("should add vectors", () => {
const v2 = v.plus(new Vector2D(3, 4));
expect(v2.x).to.equal(4);
expect(v2.y).to.equal(6);
});
it("should subtract vectors", () => {
const v2 = v.minus(new Vector2D(3, 4));
expect(v2.x).to.equal(-2);
expect(v2.y).to.equal(-2);
});
});