Skip to content

Commit e1df4a3

Browse files
committed
more test
1 parent e92f027 commit e1df4a3

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

lib/event_processor/batch_event_processor.spec.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import { advanceTimersByTime } from '../../tests/testUtils';
2626
import { getMockLogger } from '../tests/mock/mock_logger';
2727
import { getMockRepeater } from '../tests/mock/mock_repeater';
2828
import * as retry from '../utils/executor/backoff_retry_runner';
29-
import { ServiceState } from '../service';
29+
import { ServiceState, StartupLog } from '../service';
30+
import { LogLevel } from '../modules/logging';
3031

3132
const getMockDispatcher = () => {
3233
return {
@@ -50,6 +51,38 @@ describe('QueueingEventProcessor', async () => {
5051
});
5152

5253
describe('start', () => {
54+
it.only('should log startupLogs on start', () => {
55+
const startupLogs: StartupLog[] = [
56+
{
57+
level: LogLevel.WARNING,
58+
message: 'warn message',
59+
params: [1, 2]
60+
},
61+
{
62+
level: LogLevel.ERROR,
63+
message: 'error message',
64+
params: [3, 4]
65+
},
66+
];
67+
68+
const logger = getMockLogger();
69+
70+
const processor = new BatchEventProcessor({
71+
eventDispatcher: getMockDispatcher(),
72+
dispatchRepeater: getMockRepeater(),
73+
batchSize: 1000,
74+
startupLogs,
75+
});
76+
77+
processor.setLogger(logger);
78+
processor.start();
79+
80+
81+
expect(logger.log).toHaveBeenCalledTimes(2);
82+
expect(logger.log).toHaveBeenNthCalledWith(1, LogLevel.WARNING, 'warn message', 1, 2);
83+
expect(logger.log).toHaveBeenNthCalledWith(2, LogLevel.ERROR, 'error message', 3, 4);
84+
});
85+
5386
it('should resolve onRunning() when start() is called', async () => {
5487
const eventDispatcher = getMockDispatcher();
5588
const processor = new BatchEventProcessor({

vitest.config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineConfig({
2020
test: {
2121
onConsoleLog: () => true,
2222
environment: 'happy-dom',
23-
include: ['**/service.spec.ts'],
23+
include: ['**/batch_event_processor.spec.ts'],
2424
typecheck: {
2525
tsconfig: 'tsconfig.spec.json',
2626
},

0 commit comments

Comments
 (0)