fix(DestinationLocal): Fix debug log rendering, add fallback for unknown log levels, and correct error prefix typo in local destination

This commit is contained in:
2025-05-20 16:45:11 +00:00
parent a2ae8c0c83
commit a98f48409d
4 changed files with 38 additions and 6 deletions

View File

@ -92,5 +92,23 @@ tap.test('should create new line(s)', async () => {
// Multiple lines
testDestination.newLine(3);
});
// Test debug level rendering and fallback for unknown levels
tap.test('should handle debug and unknown log levels', async () => {
testDestination = new DestinationLocal();
let out = '';
const originalLog = console.log;
console.log = (msg: string) => { out += msg; };
// debug level should render message correctly
await testDestination.handleLog(createMockLogPackage('debug', 'debug 🎉'));
expect(out).toContain('debug 🎉');
// fallback for unknown level should still render message
out = '';
await testDestination.handleLog(createMockLogPackage('verbose' as any, 'verbose ⚠️'));
expect(out).toContain('verbose ⚠️');
console.log = originalLog;
});
export default tap.start();