mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 21:32:38 +02:00
refactor: remove "error" reporting level, move reportMessage to logger (#7642)
This commit is contained in:
parent
1b9bec1042
commit
bfba6a8b02
16 changed files with 117 additions and 116 deletions
|
@ -12,7 +12,6 @@ import {
|
|||
removePrefix,
|
||||
mapAsyncSequential,
|
||||
findAsyncSequential,
|
||||
reportMessage,
|
||||
} from '../jsUtils';
|
||||
|
||||
describe('removeSuffix', () => {
|
||||
|
@ -108,40 +107,3 @@ describe('findAsyncSequential', () => {
|
|||
expect(timeTotal).toBeLessThan(1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('reportMessage', () => {
|
||||
it('works with all severities', () => {
|
||||
const consoleLog = jest.spyOn(console, 'info').mockImplementation(() => {});
|
||||
const consoleWarn = jest
|
||||
.spyOn(console, 'warn')
|
||||
.mockImplementation(() => {});
|
||||
const consoleError = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
reportMessage('hey', 'ignore');
|
||||
reportMessage('hey', 'log');
|
||||
reportMessage('hey', 'warn');
|
||||
reportMessage('hey', 'error');
|
||||
expect(() =>
|
||||
reportMessage('hey', 'throw'),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"hey"`);
|
||||
expect(() =>
|
||||
// @ts-expect-error: for test
|
||||
reportMessage('hey', 'foo'),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unexpected "reportingSeverity" value: foo."`,
|
||||
);
|
||||
expect(consoleLog).toBeCalledTimes(1);
|
||||
expect(consoleLog).toBeCalledWith(
|
||||
expect.stringMatching(/.*\[INFO\].* hey/),
|
||||
);
|
||||
expect(consoleWarn).toBeCalledTimes(1);
|
||||
expect(consoleWarn).toBeCalledWith(
|
||||
expect.stringMatching(/.*\[WARNING\].* hey/),
|
||||
);
|
||||
expect(consoleError).toBeCalledTimes(1);
|
||||
expect(consoleError).toBeCalledWith(
|
||||
expect.stringMatching(/.*\[ERROR\].* hey/),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue