mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 21:18:47 +02:00
refactor: unify log format with new logger utility (#5994)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
faef753730
commit
770418f8d2
66 changed files with 717 additions and 650 deletions
|
@ -221,7 +221,11 @@ describe('docsVersion', () => {
|
|||
getVersionsFilePath(simpleSiteDir, DEFAULT_PLUGIN_ID),
|
||||
);
|
||||
expect(versions).toEqual(['1.0.0']);
|
||||
expect(consoleMock).toHaveBeenCalledWith('[docs]: version 1.0.0 created!');
|
||||
expect(consoleMock).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/.*\[SUCCESS\].* .*\[docs\].*: version .*1\.0\.0.* created!.*/,
|
||||
),
|
||||
);
|
||||
|
||||
copyMock.mockRestore();
|
||||
writeMock.mockRestore();
|
||||
|
@ -274,7 +278,11 @@ describe('docsVersion', () => {
|
|||
getVersionsFilePath(versionedSiteDir, DEFAULT_PLUGIN_ID),
|
||||
);
|
||||
expect(versions).toEqual(['2.0.0', '1.0.1', '1.0.0', 'withSlugs']);
|
||||
expect(consoleMock).toHaveBeenCalledWith('[docs]: version 2.0.0 created!');
|
||||
expect(consoleMock).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/.*\[SUCCESS\].* .*\[docs\].*: version .*2\.0\.0.* created!.*/,
|
||||
),
|
||||
);
|
||||
|
||||
copyMock.mockRestore();
|
||||
writeMock.mockRestore();
|
||||
|
@ -326,7 +334,9 @@ describe('docsVersion', () => {
|
|||
);
|
||||
expect(versions).toEqual(['2.0.0', '1.0.0']);
|
||||
expect(consoleMock).toHaveBeenCalledWith(
|
||||
'[community]: version 2.0.0 created!',
|
||||
expect.stringMatching(
|
||||
/.*\[SUCCESS\].* .*\[community\].*: version .*2.0.0.* created!.*/,
|
||||
),
|
||||
);
|
||||
|
||||
copyMock.mockRestore();
|
||||
|
|
|
@ -29,8 +29,7 @@ describe('lastUpdate', () => {
|
|||
});
|
||||
|
||||
test('non-existing file', async () => {
|
||||
const consoleMock = jest.spyOn(console, 'error');
|
||||
consoleMock.mockImplementation();
|
||||
const consoleMock = jest.spyOn(console, 'error').mockImplementation();
|
||||
const nonExistingFileName = '.nonExisting';
|
||||
const nonExistingFilePath = path.join(
|
||||
__dirname,
|
||||
|
@ -39,8 +38,8 @@ describe('lastUpdate', () => {
|
|||
);
|
||||
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
|
||||
expect(consoleMock).toHaveBeenCalledTimes(1);
|
||||
expect(consoleMock.mock.calls[0][0].message).toContain(
|
||||
' with exit code 128',
|
||||
expect(consoleMock).toHaveBeenLastCalledWith(
|
||||
expect.stringMatching(/with exit code 128/),
|
||||
);
|
||||
expect(await getFileLastUpdate(null)).toBeNull();
|
||||
expect(await getFileLastUpdate(undefined)).toBeNull();
|
||||
|
@ -60,7 +59,9 @@ describe('lastUpdate', () => {
|
|||
const lastUpdateData = await getFileLastUpdate(existingFilePath);
|
||||
expect(lastUpdateData).toBeNull();
|
||||
expect(consoleMock).toHaveBeenLastCalledWith(
|
||||
'Sorry, the docs plugin last update options require Git.',
|
||||
expect.stringMatching(
|
||||
/.*\[WARNING\].* Sorry, the docs plugin last update options require Git\..*/,
|
||||
),
|
||||
);
|
||||
|
||||
consoleMock.mockRestore();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue