mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-25 12:38:57 +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
|
@ -124,3 +124,33 @@ describe('success', () => {
|
|||
expect(consoleMock.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('report', () => {
|
||||
beforeAll(() => jest.clearAllMocks());
|
||||
it('works with all severities', () => {
|
||||
const consoleLog = jest.spyOn(console, 'info').mockImplementation(() => {});
|
||||
const consoleWarn = jest
|
||||
.spyOn(console, 'warn')
|
||||
.mockImplementation(() => {});
|
||||
logger.report('ignore')('hey');
|
||||
logger.report('log')('hey');
|
||||
logger.report('warn')('hey');
|
||||
expect(() =>
|
||||
logger.report('throw')('hey'),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"hey"`);
|
||||
expect(() =>
|
||||
// @ts-expect-error: for test
|
||||
logger.report('foo')('hey'),
|
||||
).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/),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue