-
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
d1f71f7
commit 036a709
Showing
9 changed files
with
227 additions
and
16 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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
readonly x = 0; | ||
readonly y = 0; | ||
x = 0; | ||
y = 0; | ||
} | ||
|
||
it("Should work", () => { | ||
it("Should be able to move", () => { | ||
const canvasNode = new CanvasNode(); | ||
|
||
expect(canvasNode.x).toEqual(0); | ||
expect(canvasNode.y).toEqual(0); | ||
|
||
// @ts-expect-error Property is readonly | ||
canvasNode.x = 10; | ||
canvasNode.move(10, 20); | ||
|
||
// @ts-expect-error Property is readonly | ||
canvasNode.y = 20; | ||
expect(canvasNode.x).toEqual(10); | ||
expect(canvasNode.y).toEqual(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,23 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
x = 0; | ||
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); | ||
}); |
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,23 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
x = 0; | ||
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); | ||
}); |
Empty file.
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,33 @@ | ||
import { expect, it } from "vitest"; | ||
|
||
class CanvasNode { | ||
x = 0; | ||
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); | ||
}); |
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,38 @@ | ||
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; | ||
} | ||
|
||
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); | ||
}); |
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,35 @@ | ||
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; | ||
} | ||
|
||
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 }); | ||
}); |
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,42 @@ | ||
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 }); | ||
}); |
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