Replace `vi.fn()` with `() => null` whenenver possible (#4182)
This commit is contained in:
parent
89dac46dfc
commit
ce9a75f074
|
@ -41,7 +41,7 @@ window.URL.createObjectURL = (blob: Blob) => {
|
|||
});
|
||||
return null;
|
||||
};
|
||||
navigator.getGamepads = vi.fn().mockReturnValue([]);
|
||||
navigator.getGamepads = () => [];
|
||||
global.fetch = vi.fn(MockFetch);
|
||||
Utils.setCookie(Utils.sessionIdKey, 'fake_token');
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { vi } from "vitest";
|
||||
import MockGraphics from "./mocksContainer/mockGraphics";
|
||||
import MockTextureManager from "./mockTextureManager";
|
||||
|
||||
|
@ -16,8 +15,8 @@ export class MockGameObjectCreator {
|
|||
|
||||
rexTransitionImagePack() {
|
||||
return {
|
||||
transit: vi.fn(),
|
||||
once: vi.fn(),
|
||||
transit: () => null,
|
||||
once: () => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { vi } from "vitest";
|
||||
import { MockGameObject } from "./mockGameObject";
|
||||
|
||||
/** Mocks video-related stuff */
|
||||
export class MockVideoGameObject implements MockGameObject {
|
||||
constructor() {}
|
||||
|
||||
public play = vi.fn();
|
||||
public stop = vi.fn(() => this);
|
||||
public setOrigin = vi.fn();
|
||||
public setScale = vi.fn();
|
||||
public setVisible = vi.fn();
|
||||
public play = () => null;
|
||||
public stop = () => this;
|
||||
public setOrigin = () => null;
|
||||
public setScale = () => null;
|
||||
public setVisible = () => null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import MockTextureManager from "#test/utils/mocks/mockTextureManager";
|
||||
import { vi } from "vitest";
|
||||
import { MockGameObject } from "../mockGameObject";
|
||||
|
||||
export default class MockContainer implements MockGameObject {
|
||||
|
@ -52,7 +51,7 @@ export default class MockContainer implements MockGameObject {
|
|||
/// Sets the position of this Game Object to be a relative position from the source Game Object.
|
||||
}
|
||||
|
||||
setInteractive = vi.fn();
|
||||
setInteractive = () => null;
|
||||
|
||||
setOrigin(x, y) {
|
||||
this.x = x;
|
||||
|
@ -160,10 +159,9 @@ export default class MockContainer implements MockGameObject {
|
|||
// Moves this Game Object to be below the given Game Object in the display list.
|
||||
}
|
||||
|
||||
setName = vi.fn((name: string) => {
|
||||
setName = (name: string) => {
|
||||
this.name = name;
|
||||
// return this.phaserSprite.setName(name);
|
||||
});
|
||||
};
|
||||
|
||||
bringToTop(obj) {
|
||||
// Brings this Game Object to the top of its parents display list.
|
||||
|
@ -207,5 +205,5 @@ export default class MockContainer implements MockGameObject {
|
|||
return this.list;
|
||||
}
|
||||
|
||||
disableInteractive = vi.fn();
|
||||
disableInteractive = () => null;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import Phaser from "phaser";
|
||||
import { MockGameObject } from "../mockGameObject";
|
||||
import { vi } from "vitest";
|
||||
import Sprite = Phaser.GameObjects.Sprite;
|
||||
import Frame = Phaser.Textures.Frame;
|
||||
|
||||
|
@ -102,7 +101,7 @@ export default class MockSprite implements MockGameObject {
|
|||
return this.phaserSprite.stop();
|
||||
}
|
||||
|
||||
setInteractive = vi.fn();
|
||||
setInteractive = () => null;
|
||||
|
||||
on(event, callback, source) {
|
||||
return this.phaserSprite.on(event, callback, source);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import UI from "#app/ui/ui";
|
||||
import { vi } from "vitest";
|
||||
import { MockGameObject } from "../mockGameObject";
|
||||
|
||||
export default class MockText implements MockGameObject {
|
||||
|
@ -193,11 +192,11 @@ export default class MockText implements MockGameObject {
|
|||
};
|
||||
}
|
||||
|
||||
setColor = vi.fn((color: string) => {
|
||||
setColor = (color: string) => {
|
||||
this.color = color;
|
||||
});
|
||||
};
|
||||
|
||||
setInteractive = vi.fn();
|
||||
setInteractive = () => null;
|
||||
|
||||
setShadowColor(color) {
|
||||
// Sets the shadow color.
|
||||
|
@ -223,9 +222,9 @@ export default class MockText implements MockGameObject {
|
|||
// return this.phaserText.setAlpha(alpha);
|
||||
}
|
||||
|
||||
setName = vi.fn((name: string) => {
|
||||
setName = (name: string) => {
|
||||
this.name = name;
|
||||
});
|
||||
};
|
||||
|
||||
setAlign(align) {
|
||||
// return this.phaserText.setAlign(align);
|
||||
|
|
Loading…
Reference in New Issue