-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathconsoleFormatter.test.ts
More file actions
95 lines (86 loc) · 2.73 KB
/
consoleFormatter.test.ts
File metadata and controls
95 lines (86 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {describe, it} from 'node:test';
import type {ConsoleMessageData} from '../../src/formatters/consoleFormatter.js';
import {
formatConsoleEventShort,
formatConsoleEventVerbose,
} from '../../src/formatters/consoleFormatter.js';
describe('consoleFormatter', () => {
describe('formatConsoleEventShort', () => {
it('formats a console.log message', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 1,
type: 'log',
message: 'Hello, world!',
args: [],
};
const result = formatConsoleEventShort(message);
t.assert.snapshot?.(result);
});
it('formats a console.log message with one argument', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 2,
type: 'log',
message: 'Processing file:',
args: ['file.txt'],
};
const result = formatConsoleEventShort(message);
t.assert.snapshot?.(result);
});
it('formats a console.log message with multiple arguments', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 3,
type: 'log',
message: 'Processing file:',
args: ['file.txt', 'another file'],
};
const result = formatConsoleEventShort(message);
t.assert.snapshot?.(result);
});
});
describe('formatConsoleEventVerbose', () => {
it('formats a console.log message', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 1,
type: 'log',
message: 'Hello, world!',
args: [],
};
const result = formatConsoleEventVerbose(message);
t.assert.snapshot?.(result);
});
it('formats a console.log message with one argument', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 2,
type: 'log',
message: 'Processing file:',
args: ['file.txt'],
};
const result = formatConsoleEventVerbose(message);
t.assert.snapshot?.(result);
});
it('formats a console.log message with multiple arguments', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 3,
type: 'log',
message: 'Processing file:',
args: ['file.txt', 'another file'],
};
const result = formatConsoleEventVerbose(message);
t.assert.snapshot?.(result);
});
it('formats a console.error message', t => {
const message: ConsoleMessageData = {
consoleMessageStableId: 4,
type: 'error',
message: 'Something went wrong',
};
const result = formatConsoleEventVerbose(message);
t.assert.snapshot?.(result);
});
});
});