Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#2579] Add tests confirming parent/child scene fix #2580

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/spec/ActorSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ describe('A game actor', () => {
expect(actor.graphics.anchor).toEqual(ex.vec(0, 0));
});

it('will inherit the scene from the parent entity after being added', () => {
const parent = new ex.Actor();
const child = new ex.Actor();

const engine = TestUtils.engine();

engine.add(parent);

expect(parent.scene).toBe(engine.currentScene);

parent.addChild(child);

expect(child.scene).toBe(engine.currentScene);
});

it('should create actor with valid default options', () => {
const actor = new ex.Actor();
expect(actor.anchor.toString()).toEqual('(0.5, 0.5)');
Expand Down
14 changes: 14 additions & 0 deletions src/spec/EntitySpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,21 @@ describe('An entity', () => {
expect(e.scene).toBe(null);
expect(child.scene).toBe(null);
expect(grandchild.scene).toBe(null);
});

it('will inherit the scene from the parent entity after being added', () => {
const parent = new ex.Entity([], 'parent');
const child = new ex.Entity([], 'child');

const scene = new ex.Scene();

scene.add(parent);

expect(parent.scene).toBe(scene);

parent.addChild(child);

expect(child.scene).toBe(scene);
});

it('can removeAllChildren correctly', () => {
Expand Down