Skip to content

Commit 9c03f7f

Browse files
committed
refactor: wip
1 parent d11088e commit 9c03f7f

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

packages/utils/src/lib/profiler/profiler.int.test.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,10 @@ describe('NodeJS Profiler Integration', () => {
438438
sink: mockSink,
439439
encodePerfEntry: simpleEncoder,
440440
maxQueueSize: 3,
441-
flushThreshold: 2, // Low threshold to trigger flushing
441+
flushThreshold: 2,
442442
enabled: true,
443443
});
444444

445-
// Initial stats should be zero
446445
const initialStats = profiler.stats;
447446
expect(initialStats.state).toBe('running');
448447
expect(initialStats.walOpen).toBe(true);
@@ -451,34 +450,21 @@ describe('NodeJS Profiler Integration', () => {
451450
expect(initialStats.dropped).toBe(0);
452451
expect(initialStats.written).toBe(0);
453452

454-
// Add measurements that will trigger flushing
455453
profiler.measure('operation-1', () => 'result1');
456454
profiler.measure('operation-2', () => 'result2');
457455

458-
const statsAfterMeasurements = profiler.stats;
459-
460-
// Verify all stats are present and are numbers
461-
expect(typeof statsAfterMeasurements.queued).toBe('number');
462-
expect(typeof statsAfterMeasurements.dropped).toBe('number');
463-
expect(typeof statsAfterMeasurements.written).toBe('number');
464-
465-
// Stats should be non-negative
466-
expect(statsAfterMeasurements.queued).toBeGreaterThanOrEqual(0);
467-
expect(statsAfterMeasurements.dropped).toBeGreaterThanOrEqual(0);
468-
expect(statsAfterMeasurements.written).toBeGreaterThanOrEqual(0);
456+
expect(profiler.stats.written).toBe(2);
469457

470-
// Disable profiler to flush remaining items
471458
profiler.setEnabled(false);
472459

473460
const finalStats = profiler.stats;
474-
expect(finalStats.state).toBe('idle'); // Should be idle
475-
expect(finalStats.walOpen).toBe(false); // WAL should be closed when disabled
476-
expect(finalStats.isSubscribed).toBe(false); // Should not be subscribed when disabled
477-
expect(finalStats.queued).toBe(0); // Should be cleared when disabled
461+
expect(finalStats.state).toBe('idle');
462+
expect(finalStats.walOpen).toBe(false);
463+
expect(finalStats.isSubscribed).toBe(false);
464+
expect(finalStats.queued).toBe(0);
478465
});
479466

480467
it('should write to file on flush', () => {
481-
// @TODO: Implement test when PR #1210 is merged
482468
expect(true).toBe(true);
483469
});
484470
});

0 commit comments

Comments
 (0)