Skip to content

Commit

Permalink
Add tests for Sender allowSpeech prop
Browse files Browse the repository at this point in the history
---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ant-design/x?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
afc163 committed Dec 21, 2024
1 parent b02b505 commit c7b2e13
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions components/sender/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,34 @@ describe('Sender Component', () => {
const { container } = render(<Sender readOnly />);
expect(container.querySelector('textarea')).toHaveAttribute('readonly');
});

describe('allowSpeech', () => {
it('allowSpeech prop enables speech input', () => {
const { container } = render(<Sender allowSpeech />);
const speechButton = container.querySelector('.ant-sender-actions-btn');
expect(speechButton).toBeInTheDocument();
});

it('custom speech input using allowSpeech prop', () => {
const onRecordingChange = jest.fn();
const { container } = render(
<Sender
allowSpeech={{
recording: false,
onRecordingChange,
}}
/>,
);
const speechButton = container.querySelector('.ant-sender-actions-btn');
fireEvent.click(speechButton!);
expect(onRecordingChange).toHaveBeenCalledWith(true);
});

it('speech button functionality', () => {
const { container } = render(<Sender allowSpeech />);
const speechButton = container.querySelector('.ant-sender-actions-btn');
fireEvent.click(speechButton!);
expect(container.querySelector('.ant-sender-actions-btn')).toBeInTheDocument();
});
});
});

0 comments on commit c7b2e13

Please sign in to comment.