Skip to content

Commit

Permalink
Organized Point.test.ts with describe() statements
Browse files Browse the repository at this point in the history
Will look at test.each() next
  • Loading branch information
RyanR712 committed Oct 8, 2023
1 parent 96f26ff commit 531d328
Showing 1 changed file with 41 additions and 17 deletions.
58 changes: 41 additions & 17 deletions tests/Point.test.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
import {expect, test} from "vitest";
import {describe, expect, test} from "vitest";

import {Point} from "../src/AEG/Point";

const point = new Point();
const point2 = new Point();

test("Default constructor should make a Point with X = 0.", () => {
expect(point.x).toBe(0);
});
describe("Point constructor series: ", () => {
test("Default constructor should make a Point with X = 0.", () => {
expect(point.x).toBe(0);
});

test("Default constructor should make a Point with Y = 0.", () => {
expect(point.y).toBe(0);
});
test("Default constructor should make a Point with Y = 0.", () => {
expect(point.y).toBe(0);
});

test("Point.toString() should produce a string of the form (x, y).", () => {
expect(point.toString()).toBe("(0, 0)");
});
test("Point.toString() should produce a string of the form (x, y).", () => {
expect(point.toString()).toBe("(0, 0)");
});

const point2 = new Point(10, 10);

point2.set(10, 10);
test("Two arg constructor [(Point(10, 10)] should make a Point with X = 10.", () => {
expect(point2.x).toBe(10);
});

test("New point via set method should have X = 10.", () => {
expect(point2.x).toBe(10);
test("Two arg constructor [(Point(10, 10)] should make a Point with Y = 10.", () => {
expect(point2.y).toBe(10);
});

test("Point.toString() should now produce a string of the form (x, y) with {x, y} = 10.", () => {
expect(point2.toString()).toBe("(10, 10)");
});
});

test("New point via set method should have Y = 10.", () => {
expect(point2.y).toBe(10);
describe("Point set series:", () => {
point2.set(20, 20);

test("New point via set method should have X = 20.", () => {
expect(point2.x).toBe(20);
});

test("New point via set method should have Y = 20.", () => {
expect(point2.y).toBe(20);
});
});

test("A Point's distance with itself should be 0.", () => {
expect(point.distance(point)).toBe(0);
describe("Point distance series:", () => {
test("A Point's distance with itself should be 0.", () => {
expect(point.distance(point)).toBe(0);
});

test("A Point (0, 0)'s distance with a Point (20, 20) should be sqrt(800)", () => {
expect(point.distance(point2)).toBe(Math.sqrt(800));
});
});

0 comments on commit 531d328

Please sign in to comment.