@untemps/react-vocal
Advanced tools
Comparing version 1.5.3 to 1.5.4
@@ -0,1 +1,3 @@ | ||
## [1.5.4](https://github.com/untemps/react-vocal/compare/v1.5.3...v1.5.4) (2021-04-27) | ||
## [1.5.3](https://github.com/untemps/react-vocal/compare/v1.5.2...v1.5.3) (2020-12-26) | ||
@@ -2,0 +4,0 @@ |
{ | ||
"name": "@untemps/react-vocal", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"author": "Vincent Le Badezet <v.lebadezet@untemps.net>", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:untemps/react-vocal.git", |
@@ -32,2 +32,10 @@ import React from 'react' | ||
it('renders no children element if SpeechRecognition is not supported', () => { | ||
jest.spyOn(SpeechRecognitionWrapper, 'isSupported', 'get').mockReturnValueOnce(false) | ||
const { queryByTestId } = render(getInstance(null, <div data-testid="__vocal-custom-root__" />)) | ||
expect(queryByTestId('__vocal-root__')).not.toBeInTheDocument() | ||
expect(queryByTestId('__vocal-custom-root__')).not.toBeInTheDocument() | ||
jest.clearAllMocks() | ||
}) | ||
it('renders custom children function', () => { | ||
@@ -34,0 +42,0 @@ const { queryByTestId } = render(getInstance(null, () => <div data-testid="__vocal-custom-root__" />)) |
import SpeechRecognitionWrapper from '../SpeechRecognitionWrapper' | ||
import * as userPermissionsUtils from '@untemps/user-permissions-utils' | ||
@@ -12,2 +13,23 @@ describe('SpeechRecognitionWrapper', () => { | ||
}) | ||
it('throws error when getUserMediaStream returns false value', async () => { | ||
const onError = jest.fn() | ||
jest.spyOn(userPermissionsUtils, 'getUserMediaStream').mockResolvedValueOnce(null) | ||
const wrapper = new SpeechRecognitionWrapper() | ||
wrapper.addEventListener('error', onError) | ||
await wrapper.start() | ||
expect(onError).toHaveBeenCalledWith(new Error('Unable to retrieve the stream from media device')) | ||
}) | ||
it('throws error when getUserMediaStream throws', async () => { | ||
const onError = jest.fn() | ||
const error = new Error('foo') | ||
jest.spyOn(userPermissionsUtils, 'getUserMediaStream').mockImplementationOnce(() => { | ||
throw error | ||
}) | ||
const wrapper = new SpeechRecognitionWrapper() | ||
wrapper.addEventListener('error', onError) | ||
await wrapper.start() | ||
expect(onError).toHaveBeenCalledWith(error) | ||
}) | ||
}) |
251501
1827