Skip to content

Commit 4257a1c

Browse files
Add unit test for sending typing notification within 8 secs (Azure#19359)
1 parent e11f9d1 commit 4257a1c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sdk/communication/communication-chat/test/internal/chatThreadClient.mocked.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,30 @@ describe("[Mocked] ChatThreadClient", async () => {
344344
assert.equal(request.method, "POST");
345345
});
346346

347+
it("makes only one sent typing notification request within 8 secs", async () => {
348+
const mockHttpClient = generateHttpClient(400);
349+
chatThreadClient = createChatThreadClient(threadId, mockHttpClient);
350+
const spy = sinon.spy(mockHttpClient, "sendRequest");
351+
352+
try {
353+
await chatThreadClient.sendTypingNotification();
354+
assert.fail("Should have thrown an error");
355+
} catch (e) {
356+
assert.equal(e.statusCode, 400);
357+
} finally {
358+
const result = await chatThreadClient.sendTypingNotification();
359+
assert.isFalse(result);
360+
361+
sinon.assert.calledOnce(spy);
362+
const request = spy.getCall(0).args[0];
363+
assert.equal(
364+
request.url,
365+
`${baseUri}/chat/threads/${threadId}/typing?api-version=${API_VERSION}`
366+
);
367+
assert.equal(request.method, "POST");
368+
}
369+
});
370+
347371
it("makes successful sent typing notification request with sender display name", async () => {
348372
const mockHttpClient = generateHttpClient(200);
349373
chatThreadClient = createChatThreadClient(threadId, mockHttpClient);

0 commit comments

Comments
 (0)