Commit 6feb4a32 by Ivana Huckova Committed by GitHub

Explore: Fix log level color and add tests (#21646)

parent 92ef8644
......@@ -6,6 +6,7 @@ import {
getParser,
LogsParsers,
calculateStats,
getLogLevelFromKey,
} from './logs';
describe('getLoglevel()', () => {
......@@ -23,6 +24,10 @@ describe('getLoglevel()', () => {
expect(getLogLevel('[Warn]')).toBe('warning');
});
it('returns correct log level when level is capitalized', () => {
expect(getLogLevel('WARN')).toBe(LogLevel.warn);
});
it('returns log level on line contains a log level', () => {
expect(getLogLevel('warn: it is looking bad')).toBe(LogLevel.warn);
expect(getLogLevel('2007-12-12 12:12:12 [WARN]: it is looking bad')).toBe(LogLevel.warn);
......@@ -33,6 +38,15 @@ describe('getLoglevel()', () => {
});
});
describe('getLogLevelFromKey()', () => {
it('returns correct log level', () => {
expect(getLogLevelFromKey('info')).toBe(LogLevel.info);
});
it('returns correct log level when level is capitalized', () => {
expect(getLogLevelFromKey('INFO')).toBe(LogLevel.info);
});
});
describe('calculateLogsLabelStats()', () => {
test('should return no stats for empty rows', () => {
expect(calculateLogsLabelStats([], '')).toEqual([]);
......
......@@ -33,7 +33,7 @@ export function getLogLevel(line: string): LogLevel {
}
export function getLogLevelFromKey(key: string): LogLevel {
const level = (LogLevel as any)[key];
const level = (LogLevel as any)[key.toLowerCase()];
if (level) {
return level;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment