Skip to content

Commit fe960ee

Browse files
Add test for getContextEmail capturing email per log line
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ce05e3e commit fe960ee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

__tests__/Logger-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,19 @@ test('Test Log.client()', () => {
9898
expect(mockClientLoggingCallback).toHaveBeenCalled();
9999
expect(mockClientLoggingCallback).toHaveBeenCalledWith('Test', '');
100100
});
101+
102+
test('Test getContextEmail captures email per log line', () => {
103+
const mockCallback = jest.fn();
104+
const LogWithEmail = new Logger({
105+
serverLoggingCallback: mockCallback,
106+
clientLoggingCallback: jest.fn(),
107+
getContextEmail: () => 'test@example.com',
108+
});
109+
110+
LogWithEmail.info('Test message', true);
111+
expect(mockCallback).toHaveBeenCalled();
112+
113+
const packet = JSON.parse(mockCallback.mock.calls[0][1].logPacket);
114+
delete packet[0].timestamp;
115+
expect(packet).toEqual([{message: "[info] Test message", parameters: '', email: 'test@example.com'}]);
116+
});

0 commit comments

Comments
 (0)