[Test] Fix mocks' add method to match phaser signature (#5885)

This commit is contained in:
Sirz Benjie 2025-05-28 22:18:06 -05:00 committed by GitHub
parent 86fa3198fd
commit f9e6785c35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 7 deletions

View File

@ -214,9 +214,12 @@ export default class MockContainer implements MockGameObject {
return this;
}
add(...obj: MockGameObject[]): this {
// Adds a child to this Game Object.
this.list.push(...obj);
add(obj: MockGameObject | MockGameObject[]): this {
if (Array.isArray(obj)) {
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this;
}

View File

@ -47,9 +47,13 @@ export default class MockRectangle implements MockGameObject {
this.list = [];
}
add(obj): this {
add(obj: MockGameObject | MockGameObject[]): this {
// Adds a child to this Game Object.
this.list.push(obj);
if (Array.isArray(obj)) {
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this;
}

View File

@ -201,9 +201,13 @@ export default class MockSprite implements MockGameObject {
return this;
}
add(obj): this {
add(obj: MockGameObject | MockGameObject[]): this {
// Adds a child to this Game Object.
this.list.push(obj);
if (Array.isArray(obj)) {
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this;
}