-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#154 DisplayObjectContainerのusecaseにUnitTestを追加(WIP)
- Loading branch information
Showing
6 changed files
with
198 additions
and
625 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
.../display/src/DisplayObjectContainer/usecase/DisplayObjectContainerAddChildUseCase.test.ts
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,79 @@ | ||
import { execute } from "./DisplayObjectContainerAddChildUseCase"; | ||
import { Shape } from "../../Shape"; | ||
import { DisplayObjectContainer } from "../../DisplayObjectContainer"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("DisplayObjectContainerAddChildUseCase.js test", () => | ||
{ | ||
it("execute test case1", () => | ||
{ | ||
const container = new DisplayObjectContainer(); | ||
const shape1 = new Shape(); | ||
const shape2 = new Shape(); | ||
|
||
container.changed = false; | ||
expect(container.changed).toBe(false); | ||
|
||
expect(shape1.$added).toBe(false); | ||
expect(shape1.parent).toBe(null); | ||
expect(container.children.length).toBe(0); | ||
execute(container, shape1); | ||
expect(shape1.$added).toBe(true); | ||
expect((shape1.parent as NonNullable<DisplayObjectContainer>).instanceId).toBe(container.instanceId); | ||
expect(container.changed).toBe(true); | ||
|
||
container.changed = false; | ||
expect(container.changed).toBe(false); | ||
|
||
expect(shape2.$added).toBe(false); | ||
expect(shape2.parent).toBe(null); | ||
expect(container.children.length).toBe(1); | ||
execute(container, shape2); | ||
expect(shape2.$added).toBe(true); | ||
expect((shape2.parent as NonNullable<DisplayObjectContainer>).instanceId).toBe(container.instanceId); | ||
expect(container.changed).toBe(true); | ||
|
||
expect(container.children.length).toBe(2); | ||
|
||
expect((container.children[0] as NonNullable<Shape>).instanceId).toBe(shape1.instanceId); | ||
expect((container.children[1] as NonNullable<Shape>).instanceId).toBe(shape2.instanceId); | ||
}); | ||
|
||
it("execute test case2", () => | ||
{ | ||
const container = new DisplayObjectContainer(); | ||
const shape1 = new Shape(); | ||
const shape2 = new Shape(); | ||
const shape3 = new Shape(); | ||
|
||
container.changed = false; | ||
expect(container.changed).toBe(false); | ||
|
||
expect(shape1.$added).toBe(false); | ||
expect(shape1.parent).toBe(null); | ||
expect(container.children.length).toBe(0); | ||
execute(container, shape1, 0); | ||
expect(container.children.length).toBe(1); | ||
expect(shape1.$added).toBe(true); | ||
expect((shape1.parent as NonNullable<DisplayObjectContainer>).instanceId).toBe(container.instanceId); | ||
expect(container.changed).toBe(true); | ||
|
||
container.changed = false; | ||
expect(container.changed).toBe(false); | ||
|
||
expect(shape2.$added).toBe(false); | ||
expect(shape2.parent).toBe(null); | ||
execute(container, shape2, 0); | ||
expect(container.children.length).toBe(2); | ||
expect(shape2.$added).toBe(true); | ||
expect((shape2.parent as NonNullable<DisplayObjectContainer>).instanceId).toBe(container.instanceId); | ||
expect(container.changed).toBe(true); | ||
|
||
execute(container, shape3, 0); | ||
expect(container.children.length).toBe(3); | ||
|
||
expect((container.children[0] as NonNullable<Shape>).instanceId).toBe(shape3.instanceId); | ||
expect((container.children[1] as NonNullable<Shape>).instanceId).toBe(shape2.instanceId); | ||
expect((container.children[2] as NonNullable<Shape>).instanceId).toBe(shape1.instanceId); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
...play/src/DisplayObjectContainer/usecase/DisplayObjectContainerAdvanceFrameUseCase.test.ts
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,27 @@ | ||
import { execute } from "./DisplayObjectContainerAdvanceFrameUseCase"; | ||
import { DisplayObjectContainer } from "../../DisplayObjectContainer"; | ||
import { MovieClip } from "../../MovieClip"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("DisplayObjectContainerAdvanceFrameUseCase.js test", () => | ||
{ | ||
it("execute test case1", () => | ||
{ | ||
const container = new DisplayObjectContainer(); | ||
const movieClip = container.addChild(new MovieClip()); | ||
|
||
movieClip.totalFrames = 10; | ||
movieClip.$canAction = false; | ||
movieClip.$hasTimelineHeadMoved = false; | ||
|
||
expect(movieClip.currentFrame).toBe(1); | ||
expect(movieClip.$canAction).toBe(false); | ||
expect(movieClip.$hasTimelineHeadMoved).toBe(false); | ||
|
||
execute(container); | ||
|
||
expect(movieClip.currentFrame).toBe(2); | ||
expect(movieClip.$canAction).toBe(true); | ||
expect(movieClip.$hasTimelineHeadMoved).toBe(true); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
...splay/src/DisplayObjectContainer/usecase/DisplayObjectContainerRemoveChildUseCase.test.ts
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,34 @@ | ||
import { execute } from "./DisplayObjectContainerRemoveChildUseCase"; | ||
import { Shape } from "../../Shape"; | ||
import { DisplayObjectContainer } from "../../DisplayObjectContainer"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("DisplayObjectContainerRemoveChildUseCase.js test", () => | ||
{ | ||
it("execute test case1", () => | ||
{ | ||
const container = new DisplayObjectContainer(); | ||
const shape1 = container.addChild(new Shape()); | ||
const shape2 = container.addChild(new Shape()); | ||
|
||
expect(shape1.$added).toBe(true); | ||
expect(shape1.parent?.instanceId).toBe(container.instanceId); | ||
|
||
expect(shape2.$added).toBe(true); | ||
expect(shape2.parent?.instanceId).toBe(container.instanceId); | ||
|
||
expect(container.children.length).toBe(2); | ||
execute(container, shape1); | ||
|
||
expect(container.children.length).toBe(1); | ||
expect(shape1.$added).toBe(false); | ||
expect(shape1.parent).toBe(null); | ||
|
||
execute(container, shape2); | ||
|
||
expect(container.children.length).toBe(0); | ||
expect(shape2.$added).toBe(false); | ||
expect(shape2.parent).toBe(null); | ||
}); | ||
|
||
}); |
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
Oops, something went wrong.