Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.9.13",
"version": "1.9.14",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
30 changes: 30 additions & 0 deletions src/meet/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,36 @@ describe('Meet service tests', () => {
expect(response).toEqual(usersInCallResponse);
});
});

describe('leaveCall method', () => {
const callId = 'call-123';

it('should leave a call successfully with token', async () => {
// Arrange
const { client, headers } = clientAndHeadersWithToken();
const postCall = sinon.stub(httpClient, 'post').resolves();

// Act
await client.leaveCall(callId);

// Assert
expect(postCall.firstCall.args).toEqual([`call/${callId}/users/leave`, {}, headers]);
});

it('should leave a call successfully without token', async () => {
// Arrange
const { client, headers } = clientAndHeadersWithoutToken();
const postCall = sinon.stub(httpClient, 'post').resolves();

// Act
await client.leaveCall(callId);

// Assert
expect(postCall.firstCall.args[0]).toEqual(`call/${callId}/users/leave`);
expect(postCall.firstCall.args[1]).toEqual({});
expect(postCall.firstCall.args[2]).toEqual(headers);
});
});
});

function clientAndHeadersWithToken(
Expand Down
6 changes: 6 additions & 0 deletions src/meet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export class Meet {
return this.client.post<JoinCallResponse>(`call/${callId}/users/join`, { ...payload }, headers);
}

async leaveCall(callId: string): Promise<void> {
const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders();

return this.client.post<void>(`call/${callId}/users/leave`, {}, headers);
}

async getCurrentUsersInCall(callId: string): Promise<UsersInCallResponse[]> {
const headers = this.apiSecurity?.token ? this.headersWithToken() : this.basicHeaders();

Expand Down