[Test] Add missing methods to many mocks (#5891)

This commit is contained in:
Sirz Benjie 2025-05-29 22:27:39 -05:00 committed by GitHub
parent 8fcb33d11a
commit 14e01c3da1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 56 additions and 4 deletions

View File

@ -1,4 +1,7 @@
export interface MockGameObject {
name: string;
active: boolean;
destroy?(): void;
setActive(active: boolean): this;
setName(name: string): this;
}

View File

@ -3,11 +3,20 @@ import type { MockGameObject } from "./mockGameObject";
/** Mocks video-related stuff */
export class MockVideoGameObject implements MockGameObject {
public name: string;
public active = true;
public play = () => null;
public stop = () => this;
public setOrigin = () => null;
public setScale = () => null;
public setVisible = () => null;
public setLoop = () => null;
public setOrigin = () => this;
public setScale = () => this;
public setVisible = () => this;
public setLoop = () => this;
public setName = (name: string) => {
this.name = name;
return this;
};
public setActive = (active: boolean) => {
this.active = active;
return this;
};
}

View File

@ -14,6 +14,7 @@ export default class MockContainer implements MockGameObject {
protected textureManager;
public list: MockGameObject[] = [];
public name: string;
public active = true;
constructor(textureManager: MockTextureManager, x: number, y: number) {
this.x = x;
@ -306,4 +307,9 @@ export default class MockContainer implements MockGameObject {
}
return this;
}
setActive(active: boolean): this {
this.active = active;
return this;
}
}

View File

@ -4,6 +4,7 @@ export default class MockGraphics implements MockGameObject {
private scene;
public list: MockGameObject[] = [];
public name: string;
public active = true;
constructor(textureManager, _config) {
this.scene = textureManager.scene;
}
@ -113,4 +114,9 @@ export default class MockGraphics implements MockGameObject {
copyPosition(_source): this {
return this;
}
setActive(active: boolean): this {
this.active = active;
return this;
}
}

View File

@ -5,6 +5,7 @@ export default class MockRectangle implements MockGameObject {
private scene;
public list: MockGameObject[] = [];
public name: string;
public active = true;
constructor(textureManager, _x, _y, _width, _height, fillColor) {
this.fillColor = fillColor;
@ -96,4 +97,9 @@ export default class MockRectangle implements MockGameObject {
off(): this {
return this;
}
setActive(active: boolean): this {
this.active = active;
return this;
}
}

View File

@ -13,6 +13,7 @@ export default class MockSprite implements MockGameObject {
public anims;
public list: MockGameObject[] = [];
public name: string;
public active = true;
constructor(textureManager, x, y, texture) {
this.textureManager = textureManager;
this.scene = textureManager.scene;
@ -247,4 +248,9 @@ export default class MockSprite implements MockGameObject {
this.phaserSprite.copyPosition(obj);
return this;
}
setActive(active: boolean): this {
this.phaserSprite.setActive(active);
return this;
}
}

View File

@ -12,6 +12,7 @@ export default class MockText implements MockGameObject {
public text = "";
public name: string;
public color?: string;
public active = true;
constructor(textureManager, _x, _y, _content, _styleOptions) {
this.scene = textureManager.scene;
@ -354,4 +355,8 @@ export default class MockText implements MockGameObject {
// biome-ignore lint/complexity/noBannedTypes: This matches the signature of the class this mocks
on(_event: string | symbol, _fn: Function, _context?: any) {}
setActive(_active: boolean): this {
return this;
}
}

View File

@ -12,6 +12,7 @@ export default class MockTexture implements MockGameObject {
public frames: object;
public firstFrame: string;
public name: string;
public active: boolean;
constructor(manager, key: string, source) {
this.manager = manager;
@ -39,4 +40,14 @@ export default class MockTexture implements MockGameObject {
getSourceImage() {
return null;
}
setActive(active: boolean): this {
this.active = active;
return this;
}
setName(name: string): this {
this.name = name;
return this;
}
}