Skip to content

Commit 533f97a

Browse files
committed
test: synchronous log call
1 parent 075a733 commit 533f97a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/compass-web/src/logger.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,25 @@ describe('useCompassWebLogger', function () {
5959
},
6060
]);
6161
});
62+
63+
it('should call onLog hook synchronously', function () {
64+
let callbackExecuted = false;
65+
const onLog = Sinon.stub().callsFake(() => {
66+
callbackExecuted = true;
67+
});
68+
69+
const {
70+
result: { current: logger },
71+
} = renderLoggerHook({ onLog });
72+
73+
// Callback should not have been called yet
74+
expect(callbackExecuted).to.be.false;
75+
76+
// Call the logger
77+
logger.log.info(mongoLogId(456), 'Test', 'sync test');
78+
79+
// Callback should have been called synchronously before this assertion
80+
expect(callbackExecuted).to.be.true;
81+
expect(onLog).to.have.been.calledOnce;
82+
});
6283
});

0 commit comments

Comments
 (0)