-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fae1434
commit d9c1fca
Showing
251 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
#x; | ||
#y; | ||
|
||
constructor(position?: { x: number; y: number }) { | ||
this.#x = position?.x ?? 0; | ||
this.#y = position?.y ?? 0; | ||
} | ||
|
||
get position() { | ||
return { | ||
x: this.#x, | ||
y: this.#y, | ||
}; | ||
} | ||
|
||
move(x: number, y: number) { | ||
this.#x = x; | ||
this.#y = y; | ||
} | ||
} | ||
|
||
it("Should be able to move", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect(canvasNode.position).toEqual({ x: 0, y: 0 }); | ||
|
||
canvasNode.move(10, 20); | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); | ||
|
||
it("Should be able to receive an initial position", () => { | ||
const canvasNode = new CanvasNode({ | ||
x: 10, | ||
y: 20, | ||
}); | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); | ||
|
||
it("Should not be able to access x and y from the outside", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect( | ||
// @ts-expect-error | ||
canvasNode.#x, | ||
).toEqual(undefined); | ||
expect( | ||
// @ts-expect-error | ||
canvasNode.#y, | ||
).toEqual(undefined); | ||
}); | ||
|
||
it("Should let you set the position", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect(canvasNode.position).toEqual({ x: 0, y: 0 }); | ||
|
||
canvasNode.position = { x: 10, y: 20 }; | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
#x; | ||
#y; | ||
|
||
constructor(position?: { x: number; y: number }) { | ||
this.#x = position?.x ?? 0; | ||
this.#y = position?.y ?? 0; | ||
} | ||
|
||
get position() { | ||
return { | ||
x: this.#x, | ||
y: this.#y, | ||
}; | ||
} | ||
|
||
set position(pos) { | ||
this.#x = pos.x; | ||
this.#y = pos.y; | ||
} | ||
|
||
move(x: number, y: number) { | ||
this.#x = x; | ||
this.#y = y; | ||
} | ||
} | ||
|
||
it("Should be able to move", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect(canvasNode.position).toEqual({ x: 0, y: 0 }); | ||
|
||
canvasNode.move(10, 20); | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); | ||
|
||
it("Should be able to receive an initial position", () => { | ||
const canvasNode = new CanvasNode({ | ||
x: 10, | ||
y: 20, | ||
}); | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); | ||
|
||
it("Should not be able to access x and y from the outside", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect( | ||
// @ts-expect-error | ||
canvasNode.#x, | ||
).toEqual(undefined); | ||
expect( | ||
// @ts-expect-error | ||
canvasNode.#y, | ||
).toEqual(undefined); | ||
}); | ||
|
||
it("Should let you set the position", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect(canvasNode.position).toEqual({ x: 0, y: 0 }); | ||
|
||
canvasNode.position = { x: 10, y: 20 }; | ||
|
||
expect(canvasNode.position).toEqual({ x: 10, y: 20 }); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.