Skip to content

Commit 7bc6586

Browse files
committed
test: enhance leaveCall tests to include userId payload scenarios
1 parent 328d59b commit 7bc6586

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

test/drive/meet/index.test.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { ApiSecurity, AppDetails } from '../../../src/shared';
33
import { basicHeaders, headersWithToken } from '../../../src/shared/headers';
44
import { HttpClient } from '../../../src/shared/http/client';
55
import { Meet } from '../../../src/meet/index';
6-
import { CreateCallResponse, JoinCallPayload, JoinCallResponse, UsersInCallResponse } from '../../../src/meet/types';
6+
import {
7+
CreateCallResponse,
8+
JoinCallPayload,
9+
JoinCallResponse,
10+
LeaveCallPayload,
11+
UsersInCallResponse,
12+
} from '../../../src/meet/types';
713

814
describe('Meet service tests', () => {
915
beforeEach(() => {
@@ -131,7 +137,7 @@ describe('Meet service tests', () => {
131137
describe('leaveCall method', () => {
132138
const callId = 'call-123';
133139

134-
it('should leave a call successfully with token', async () => {
140+
it('should leave a call successfully with token and no payload', async () => {
135141
// Arrange
136142
const { client, headers } = clientAndHeadersWithToken();
137143
const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue(undefined);
@@ -143,7 +149,7 @@ describe('Meet service tests', () => {
143149
expect(postCall).toHaveBeenCalledWith(`call/${callId}/users/leave`, {}, headers);
144150
});
145151

146-
it('should leave a call successfully without token', async () => {
152+
it('should leave a call successfully without token and no payload', async () => {
147153
// Arrange
148154
const { client, headers } = clientAndHeadersWithoutToken();
149155
const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue(undefined);
@@ -154,6 +160,26 @@ describe('Meet service tests', () => {
154160
// Assert
155161
expect(postCall).toHaveBeenCalledWith(`call/${callId}/users/leave`, {}, headers);
156162
});
163+
164+
it('should send userId in body when anonymous user leaves with token', async () => {
165+
const payload: LeaveCallPayload = { userId: 'anon-uuid-456' };
166+
const { client, headers } = clientAndHeadersWithToken();
167+
const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue(undefined);
168+
169+
await client.leaveCall(callId, payload);
170+
171+
expect(postCall).toHaveBeenCalledWith(`call/${callId}/users/leave`, { userId: 'anon-uuid-456' }, headers);
172+
});
173+
174+
it('should send userId in body when anonymous user leaves without token', async () => {
175+
const payload: LeaveCallPayload = { userId: 'anon-uuid-789' };
176+
const { client, headers } = clientAndHeadersWithoutToken();
177+
const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue(undefined);
178+
179+
await client.leaveCall(callId, payload);
180+
181+
expect(postCall).toHaveBeenCalledWith(`call/${callId}/users/leave`, { userId: 'anon-uuid-789' }, headers);
182+
});
157183
});
158184
});
159185

0 commit comments

Comments
 (0)