mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
JEST: Quiet Jest tests output on expected failures (#2332)
This commit is contained in:
@@ -57,12 +57,17 @@ describe("setTheme", () => {
|
||||
});
|
||||
|
||||
describe("Failure", () => {
|
||||
let spyConErr: jest.Spied<typeof console.error>;
|
||||
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<typeof console.error>;
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user