Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test case for useSpeech #387

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions components/sender/__tests__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Sender Component allowSpeech 1`] = `null`;

exports[`Sender Component allowSpeech 2`] = `null`;

exports[`Sender Component loading state 1`] = `
<DocumentFragment>
<div
Expand Down
16 changes: 16 additions & 0 deletions components/sender/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,20 @@ describe('Sender Component', () => {
const { container } = render(<Sender readOnly />);
expect(container.querySelector('textarea')).toHaveAttribute('readonly');
});

it('allowSpeech', () => {
const { container } = render(<Sender allowSpeech />);
expect(container.querySelector('.ant-sender-action-list-presets')).toMatchSnapshot();

// 不支持语音时不显示语音按钮
const mockSpeechRecognition = (window as any).SpeechRecognition;
afc163 marked this conversation as resolved.
Show resolved Hide resolved
delete (window as any).SpeechRecognition;
delete (window as any).webkitSpeechRecognition;

const { container: noSpeechContainer } = render(<Sender allowSpeech />);
expect(noSpeechContainer.querySelector('.ant-sender-action-list-presets')).toMatchSnapshot();

// 恢复 mock
(window as any).SpeechRecognition = mockSpeechRecognition;
});
});
Loading