@testing-library/react-hooks
Advanced tools
Comparing version 2.0.3 to 3.0.0
@@ -15,2 +15,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "cleanup", { | ||
enumerable: true, | ||
get: function get() { | ||
return _cleanup.cleanup; | ||
} | ||
}); | ||
@@ -21,2 +27,4 @@ var _react = _interopRequireWildcard(require("react")); | ||
var _cleanup = require("./cleanup"); | ||
function TestHook(_ref) { | ||
@@ -120,4 +128,13 @@ var callback = _ref.callback, | ||
var _testRenderer = testRenderer, | ||
_unmount = _testRenderer.unmount, | ||
unmount = _testRenderer.unmount, | ||
update = _testRenderer.update; | ||
function unmountHook() { | ||
(0, _reactTestRenderer.act)(function () { | ||
(0, _cleanup.removeCleanup)(unmountHook); | ||
unmount(); | ||
}); | ||
} | ||
(0, _cleanup.addCleanup)(unmountHook); | ||
var waitingForNextUpdate = null; | ||
@@ -150,8 +167,4 @@ | ||
}, | ||
unmount: function unmount() { | ||
(0, _reactTestRenderer.act)(function () { | ||
_unmount(); | ||
}); | ||
} | ||
unmount: unmountHook | ||
}; | ||
} |
{ | ||
"name": "@testing-library/react-hooks", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Simple and complete React hooks testing utilities that encourage good testing practices.", | ||
@@ -41,9 +41,9 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "7.6.2", | ||
"@babel/core": "7.6.2", | ||
"@babel/cli": "7.6.4", | ||
"@babel/core": "7.6.4", | ||
"@babel/plugin-proposal-object-rest-spread": "7.6.2", | ||
"@babel/plugin-transform-modules-commonjs": "7.6.0", | ||
"@babel/plugin-transform-runtime": "7.6.2", | ||
"@babel/preset-env": "7.6.2", | ||
"@babel/preset-react": "7.0.0", | ||
"@babel/preset-env": "7.6.3", | ||
"@babel/preset-react": "7.6.3", | ||
"all-contributors-cli": "6.9.1", | ||
@@ -56,12 +56,12 @@ "babel-eslint": "10.0.3", | ||
"eslint": "6.5.1", | ||
"eslint-config-prettier": "6.3.0", | ||
"eslint-config-prettier": "6.4.0", | ||
"eslint-plugin-prettier": "3.1.1", | ||
"husky": "3.0.8", | ||
"husky": "3.0.9", | ||
"jest": "24.9.0", | ||
"lint-staged": "9.4.1", | ||
"lint-staged": "9.4.2", | ||
"prettier": "1.18.2", | ||
"prettier-eslint": "9.0.0", | ||
"prettier-eslint-cli": "5.0.0", | ||
"react": "16.10.1", | ||
"react-test-renderer": "16.10.1" | ||
"react": "16.10.2", | ||
"react-test-renderer": "16.10.2" | ||
}, | ||
@@ -68,0 +68,0 @@ "peerDependencies": { |
import React, { Suspense } from 'react' | ||
import { act, create } from 'react-test-renderer' | ||
import { cleanup, addCleanup, removeCleanup } from './cleanup' | ||
@@ -76,2 +77,11 @@ function TestHook({ callback, hookProps, onError, children }) { | ||
function unmountHook() { | ||
act(() => { | ||
removeCleanup(unmountHook) | ||
unmount() | ||
}) | ||
} | ||
addCleanup(unmountHook) | ||
let waitingForNextUpdate = null | ||
@@ -97,10 +107,6 @@ const resolveOnNextUpdate = (resolve) => { | ||
}, | ||
unmount: () => { | ||
act(() => { | ||
unmount() | ||
}) | ||
} | ||
unmount: unmountHook | ||
} | ||
} | ||
export { renderHook, act } | ||
export { renderHook, cleanup, act } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26009
7
334
2