Skip to content

Commit 210d391

Browse files
committed
test: Fixed typing state test
1 parent c98cb22 commit 210d391

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/components/chat/chat-state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ export class ChatState {
294294
/**
295295
* Adds files as attachments to the input.
296296
* Emits 'igcAttachmentChange' event which can be canceled to prevent adding.
297-
* @param files Array of File objects to attach
298297
* @internal
299298
*/
300299
public attachFilesWithEvent(files: File[]): void {

src/components/chat/chat.spec.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { elementUpdated, expect, fixture } from '@open-wc/testing';
1+
import { elementUpdated, expect, fixture, waitUntil } from '@open-wc/testing';
22
import { html, nothing } from 'lit';
3-
import { type SinonFakeTimers, spy, stub, useFakeTimers } from 'sinon';
3+
import { spy, stub } from 'sinon';
44
import type IgcIconButtonComponent from '../button/icon-button.js';
55
import IgcChipComponent from '../chip/chip.js';
66
import { enterKey } from '../common/controllers/key-bindings.js';
@@ -117,15 +117,9 @@ describe('Chat', () => {
117117
];
118118

119119
let chat: IgcChatComponent;
120-
let clock: SinonFakeTimers;
121120

122121
beforeEach(async () => {
123122
chat = await fixture<IgcChatComponent>(html`<igc-chat></igc-chat>`);
124-
clock = useFakeTimers({ toFake: ['setTimeout'] });
125-
});
126-
127-
afterEach(() => {
128-
clock.restore();
129123
});
130124

131125
describe('Initialization', () => {
@@ -889,24 +883,21 @@ describe('Chat', () => {
889883

890884
it('emits igcTypingChange', async () => {
891885
const eventSpy = spy(chat, 'emitEvent');
892-
const textArea = getChatDOM(chat).input.textarea!;
886+
const textArea = getChatDOM(chat).input.textarea;
893887

894-
simulateFocus(textArea);
888+
chat.options = { stopTypingDelay: 100 };
895889
simulateKeyboard(textArea, 'a');
896890
await elementUpdated(chat);
897891

898892
expect(eventSpy).calledWith('igcTypingChange');
899-
expect(eventSpy.getCall(1).args[1]?.detail).to.deep.equal({
900-
isTyping: true,
901-
});
893+
expect(eventSpy.firstCall.args[1]?.detail).to.eql({ isTyping: true });
902894

903-
clock.tick(3001);
904-
await elementUpdated(chat);
895+
eventSpy.resetHistory();
896+
897+
await waitUntil(() => eventSpy.calledWith('igcTypingChange'));
905898

906899
expect(eventSpy).calledWith('igcTypingChange');
907-
expect(eventSpy.getCall(2).args[1]?.detail).to.deep.equal({
908-
isTyping: false,
909-
});
900+
expect(eventSpy.firstCall.args[1]?.detail).to.eql({ isTyping: false });
910901
});
911902

912903
it('emits igcInputFocus', async () => {

0 commit comments

Comments
 (0)