Skip to content

Commit

Permalink
2023-09-06T08:52:10.116Z
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Sep 6, 2023
1 parent ed87008 commit 530d539
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 80 deletions.
1 change: 1 addition & 0 deletions plan.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
JSDoc section?
Setters in classes?
Add decorators when they're supported in vite
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect, it } from "vitest";

class CanvasNode {
x: number;
y: number;

constructor(position?: { x: number; y: number }) {
this.x = position?.x ?? 0;
this.y = position?.y ?? 0;
}

move(x: number, y: number) {
this.x = x;
this.y = y;
}
}

it("Should be able to move", () => {
const canvasNode = new CanvasNode();

expect(canvasNode.x).toEqual(0);
expect(canvasNode.y).toEqual(0);

canvasNode.move(10, 20);

expect(canvasNode.x).toEqual(10);
expect(canvasNode.y).toEqual(20);
});

it("Should be able to receive an initial position", () => {
const canvasNode = new CanvasNode({
x: 10,
y: 20,
});

expect(canvasNode.x).toEqual(10);
expect(canvasNode.y).toEqual(20);
});
4 changes: 2 additions & 2 deletions src/030-classes/108-getters.problem.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
x;
y;
x: number;
y: number;

constructor(position?: { x: number; y: number }) {
this.x = position?.x ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/108-getters.solution.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
x;
y;
x: number;
y: number;

constructor(position?: { x: number; y: number }) {
this.x = position?.x ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/109-public-and-private-properties.problem.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
x;
y;
x: number;
y: number;

constructor(position?: { x: number; y: number }) {
this.x = position?.x ?? 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
private x;
private y;
private x: number;
private y: number;

constructor(position?: { x: number; y: number }) {
this.x = position?.x ?? 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
#x;
#y;
#x: number;
#y: number;

constructor(position?: { x: number; y: number }) {
this.#x = position?.x ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/110-setters.problem.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
#x;
#y;
#x: number;
#y: number;

constructor(position?: { x: number; y: number }) {
this.#x = position?.x ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/110-setters.solution.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, it } from "vitest";

class CanvasNode {
#x;
#y;
#x: number;
#y: number;

constructor(position?: { x: number; y: number }) {
this.#x = position?.x ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/111-extending-other-classes.problem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { expect, it } from "vitest";
type ViewMode = "hidden" | "visible" | "selected";

class CanvasNode {
#x;
#y;
#x: number;
#y: number;
#viewMode: ViewMode;

constructor(options?: { x: number; y: number; viewMode?: ViewMode }) {
Expand Down
4 changes: 2 additions & 2 deletions src/030-classes/111-extending-other-classes.solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ interface ShapeOptions {
}

class Shape {
#x;
#y;
#x: number;
#y: number;

constructor(initial?: ShapeOptions) {
this.#x = initial?.x ?? 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface ShapeOptions {

// How do we ensure our Shape class matches a certain type?
class Shape {
#x;
#y;
#x: number;
#y: number;

constructor(initial?: ShapeOptions) {
this.#x = initial?.x ?? 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type IShape = {
};

class Shape implements IShape {
#x;
#y;
#x: number;
#y: number;

constructor(initial?: ShapeOptions) {
this.#x = initial?.x ?? 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface IShape {
}

class Shape implements IShape {
#x;
#y;
#x: number;
#y: number;

constructor(initial?: ShapeOptions) {
this.#x = initial?.x ?? 0;
Expand Down
1 change: 0 additions & 1 deletion src/030-classes/114-decorators.problem.ts

This file was deleted.

55 changes: 0 additions & 55 deletions src/030-classes/114-decorators.solution.ts

This file was deleted.

0 comments on commit 530d539

Please sign in to comment.