Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions sdks/typescript/src/clients/event/event-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,38 @@ describe('EventClient', () => {
});
});

it('should apply options.priority and options.scope as defaults in bulkPush', async () => {
const clientSpy = jest.spyOn(client.client, 'bulkPush').mockResolvedValue({
events: [],
});

const events = [
{ payload: { foo: 'bar1' } },
{ payload: { foo: 'bar2' }, priority: 7, scope: 'per-event-scope' },
];

await client.bulkPush('type', events, { priority: 3, scope: 'shared-scope' });

expect(clientSpy).toHaveBeenCalledWith({
events: [
{
key: 'type',
payload: '{"foo":"bar1"}',
eventTimestamp: expect.any(Date),
priority: 3,
scope: 'shared-scope',
},
{
key: 'type',
payload: '{"foo":"bar2"}',
eventTimestamp: expect.any(Date),
priority: 7,
scope: 'per-event-scope',
},
],
});
});

it('should throw an error when bulkPush fails', async () => {
// Mock the bulkPush method to throw an error
const clientSpy = jest.spyOn(client.client, 'bulkPush');
Expand Down
4 changes: 2 additions & 2 deletions sdks/typescript/src/clients/event/event-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export class EventClient {
payload: JSON.stringify(input.payload),
eventTimestamp: new Date(),
additionalMetadata: Object.keys(enhanced).length > 0 ? JSON.stringify(enhanced) : undefined,
priority: input.priority,
scope: input.scope,
priority: input.priority ?? options.priority,
scope: input.scope ?? options.scope,
};
});

Expand Down
Loading