diff --git a/test/jest/Netscript/UserInterface.test.ts b/test/jest/Netscript/UserInterface.test.ts index f0a483167..858b2021c 100644 --- a/test/jest/Netscript/UserInterface.test.ts +++ b/test/jest/Netscript/UserInterface.test.ts @@ -57,12 +57,17 @@ describe("setTheme", () => { }); describe("Failure", () => { + let spyConErr: jest.Spied; + beforeEach(() => { + spyConErr = jest.spyOn(console, "error").mockImplementation(() => null); + }); test("Full theme", () => { const ns = getNS(); const newTheme = ns.ui.getTheme(); newTheme.primary = ""; ns.ui.setTheme(newTheme); const result = ns.ui.getTheme(); + expect(spyConErr).toHaveBeenCalled(); expect(result.primary).toStrictEqual(defaultTheme.primary); }); test("Partial theme", () => { @@ -72,8 +77,12 @@ describe("setTheme", () => { }; ns.ui.setTheme(newTheme as unknown as UserInterfaceTheme); const result = ns.ui.getTheme(); + expect(spyConErr).toHaveBeenCalled(); expect(result.primary).toStrictEqual(defaultTheme.primary); }); + afterEach(() => { + spyConErr.mockRestore(); + }); }); }); @@ -123,12 +132,17 @@ describe("setStyles", () => { }); describe("Failure", () => { + let spyConErr: jest.Spied; + beforeEach(() => { + spyConErr = jest.spyOn(console, "error").mockImplementation(() => null); + }); test("Full styles", () => { const ns = getNS(); const newStyles = ns.ui.getStyles(); (newStyles.fontFamily as unknown) = 123; ns.ui.setStyles(newStyles); const result = ns.ui.getStyles(); + expect(spyConErr).toHaveBeenCalled(); expect(result.fontFamily).toStrictEqual(defaultStyles.fontFamily); }); test("Partial styles", () => { @@ -138,7 +152,11 @@ describe("setStyles", () => { }; ns.ui.setStyles(newStyles as unknown as IStyleSettings); const result = ns.ui.getStyles(); + expect(spyConErr).toHaveBeenCalled(); expect(result.fontFamily).toStrictEqual(defaultStyles.fontFamily); }); + afterEach(() => { + spyConErr.mockRestore(); + }); }); });