@untemps/react-vocal 1.7.6 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,11 @@
1
- const { toBeInTheDocument, toHaveAttribute, toHaveStyle } = require('@testing-library/jest-dom/matchers')
1
+ import '@testing-library/jest-dom/extend-expect'
2
+ import { toBeInTheDocument, toHaveAttribute, toHaveStyle } from '@testing-library/jest-dom/matchers'
2
3
 
3
4
  expect.extend({ toBeInTheDocument, toHaveAttribute, toHaveStyle })
4
5
 
6
+ global.navigator = {
7
+ userAgent: 'node.js',
8
+ }
5
9
  global.PermissionStatus = jest.fn(() => ({
6
10
  state: 'granted',
7
11
  addEventListener: jest.fn(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untemps/react-vocal",
3
- "version": "1.7.6",
3
+ "version": "1.7.9",
4
4
  "author": "Vincent Le Badezet <v.lebadezet@untemps.net>",
5
5
  "repository": "git@github.com:untemps/react-vocal.git",
6
6
  "license": "MIT",
@@ -22,6 +22,9 @@
22
22
  },
23
23
  "main": "dist/index.js",
24
24
  "module": "dist/index.es.js",
25
+ "engines": {
26
+ "node": ">=14"
27
+ },
25
28
  "devDependencies": {
26
29
  "@babel/cli": "^7.12.10",
27
30
  "@babel/core": "^7.12.10",
@@ -42,10 +45,12 @@
42
45
  "@testing-library/jest-dom": "^5.11.6",
43
46
  "@testing-library/react": "^11.2.2",
44
47
  "@testing-library/react-hooks": "^3.7.0",
48
+ "@untemps/utils": "^1.7.1",
45
49
  "babel-jest": "^26.6.3",
46
50
  "cross-env": "^7.0.3",
47
51
  "husky": "^4.3.6",
48
- "jest": "^26.6.3",
52
+ "jest": "^28.0.0-alpha.8",
53
+ "jest-environment-jsdom": "^28.0.0-alpha.8",
49
54
  "prettier": "^2.2.1",
50
55
  "prop-types": "^15.7.2",
51
56
  "react": "^17.0.1",
@@ -81,7 +86,7 @@
81
86
  },
82
87
  "release": {
83
88
  "branches": [
84
- "master"
89
+ "main"
85
90
  ],
86
91
  "plugins": [
87
92
  [
@@ -1,8 +1,7 @@
1
1
  import React, { cloneElement, isValidElement, useRef, useState } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { Vocal as SpeechRecognitionWrapper } from '@untemps/vocal'
4
-
5
- import isFunc from '../utils/isFunc'
4
+ import isFunction from '@untemps/utils/function/isFunction'
6
5
 
7
6
  import useVocal from '../hooks/useVocal'
8
7
  import useTimeout from '../hooks/useTimeout'
@@ -166,7 +165,7 @@ const Vocal = ({
166
165
 
167
166
  const _renderChildren = (children) => {
168
167
  if (SpeechRecognitionWrapper.isSupported) {
169
- if (isFunc(children)) {
168
+ if (isFunction(children)) {
170
169
  return children(startRecognition, stopRecognition, isListening)
171
170
  } else if (isValidElement(children)) {
172
171
  return cloneElement(children, {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
1
5
  import React from 'react'
2
6
  import { render } from '@testing-library/react'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
1
5
  import React from 'react'
2
6
  import { waitFor } from '@testing-library/dom'
3
7
  import { act, fireEvent, render } from '@testing-library/react'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
1
5
  import React from 'react'
2
6
  import { waitFor } from '@testing-library/dom'
3
7
  import { act, fireEvent, render } from '@testing-library/react'
@@ -1,57 +0,0 @@
1
- import isFunc from '../isFunc'
2
-
3
- const noop = () => null
4
- const asyncNoop = async () => {}
5
- const genNoop = function* () {}
6
-
7
- describe('isFunc', () => {
8
- it('returns true for function', function () {
9
- expect(isFunc(noop)).toBeTruthy()
10
- })
11
-
12
- it('returns true for async function', function () {
13
- expect(isFunc(asyncNoop)).toBeTruthy()
14
- })
15
-
16
- it('returns true for generator function', function () {
17
- expect(isFunc(genNoop)).toBeTruthy()
18
- })
19
-
20
- it('returns false for array', function () {
21
- expect(isFunc([1, 2, 3])).toBeFalsy()
22
- })
23
-
24
- it('returns false for boolean', function () {
25
- expect(isFunc(true)).toBeFalsy()
26
- })
27
-
28
- it('returns false for date', function () {
29
- expect(isFunc(new Date())).toBeFalsy()
30
- })
31
-
32
- it('returns false for error', function () {
33
- expect(isFunc(new Error())).toBeFalsy()
34
- })
35
-
36
- it('returns false for object', function () {
37
- expect(isFunc({ a: 1 })).toBeFalsy()
38
- })
39
-
40
- it('returns false for number', function () {
41
- expect(isFunc(1)).toBeFalsy()
42
- })
43
-
44
- it('returns false for regex', function () {
45
- expect(isFunc(/foo/)).toBeFalsy()
46
- })
47
-
48
- it('returns false for string', function () {
49
- expect(isFunc('foo')).toBeFalsy()
50
- })
51
-
52
- it('returns false for DOM node', function () {
53
- if (document) {
54
- expect(isFunc(document.getElementsByTagName('body'))).toBeFalsy()
55
- }
56
- })
57
- })
@@ -1 +0,0 @@
1
- export default (val) => typeof val === 'function'