1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

All: Improves formatting of log statements

This commit is contained in:
Laurent Cozic
2024-05-01 10:36:20 +01:00
parent 8ec233f59c
commit aac8d58372
2 changed files with 37 additions and 11 deletions

View File

@ -57,6 +57,22 @@ describe('Logger', () => {
jest.useRealTimers();
});
test.each([
[['one', 'two'], 'one two'],
[[true, false, undefined, null], '<true> <false> <undefined> <null>'],
[['123', 123], '123 123'],
[[['a', 'b', ['sub1', 'sub2']]], '[a, b, [sub1, sub2]]'],
[[''], ''],
[[{ that: 'is json', sub: { key1: 'abc', key2: 'def' } }], '{"that":"is json","sub":{"key1":"abc","key2":"def"}}'],
])('should format messages correctly', async (input, expected) => {
jest.useFakeTimers().setSystemTime(new Date('2020-01-01'));
const logger = createLogger();
logger.info(...input);
await logger.waitForFileWritesToComplete_();
expect(await getLogContent()).toBe(`2020-01-01 00:00:00: testing: ${expected}\n`);
jest.useRealTimers();
});
// it('should keep the last lines', async () => {
// jest.useFakeTimers().setSystemTime(new Date('2020-01-01'));