diff --git a/src/__tests__/courier-client.test.tsx b/src/__tests__/courier-client.test.tsx index b6d8664..a76c189 100644 --- a/src/__tests__/courier-client.test.tsx +++ b/src/__tests__/courier-client.test.tsx @@ -57,6 +57,30 @@ describe('CourierClient', () => { expect(client.options.showLogs).toBe(true); }); + it('passes connectionId through to addClient', () => { + const client = new CourierClient({ + userId: 'u1', + clientKey: 'ck-1', + connectionId: 'conn-1', + showLogs: false, + }); + + expect(client.options.connectionId).toBe('conn-1'); + expect(Modules.Client.addClient).toHaveBeenCalledWith( + expect.objectContaining({ clientKey: 'ck-1', connectionId: 'conn-1' }) + ); + }); + + it('leaves connectionId undefined when not provided', () => { + const client = new CourierClient({ + userId: 'u1', + clientKey: 'ck-1', + showLogs: false, + }); + + expect(client.options.connectionId).toBeUndefined(); + }); + it('defaults showLogs when omitted', () => { const client = new CourierClient({ userId: 'u1' }); expect(typeof client.options.showLogs).toBe('boolean'); diff --git a/src/client/CourierClient.tsx b/src/client/CourierClient.tsx index 1661102..d3788b9 100644 --- a/src/client/CourierClient.tsx +++ b/src/client/CourierClient.tsx @@ -38,7 +38,7 @@ export class CourierClient extends ClientModule { showLogs: props.showLogs ?? __DEV__, jwt: props.jwt, clientKey: props.clientKey, - connectionId: props.clientKey, + connectionId: props.connectionId, tenantId: props.tenantId, apiUrls: props.apiUrls ? { ...props.apiUrls } : undefined, };