context-thief
Advanced tools
Comparing version 1.0.5 to 1.1.0
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -26,8 +30,9 @@ if (k2 === undefined) k2 = k; | ||
const contextValue = {}; | ||
const ContextThief = ({ children }) => { | ||
const value = (0, react_1.useContext)(context); | ||
contextValue.current = value; | ||
return react_1.default.createElement(react_1.default.Fragment, null, children); | ||
}; | ||
return { | ||
ContextThief: ({ children }) => { | ||
const value = react_1.useContext(context); | ||
contextValue.current = value; | ||
return react_1.default.createElement(react_1.default.Fragment, null, children); | ||
}, | ||
ContextThief, | ||
contextValue, | ||
@@ -34,0 +39,0 @@ }; |
{ | ||
"name": "context-thief", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "Helper function to steal React context values for testing", | ||
@@ -44,43 +44,31 @@ "keywords": [ | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "@commitlint/prompt" | ||
} | ||
"release": { | ||
"extends": "conventional-changelog-evelyn/release.config.js" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/prompt": "^12.1.4", | ||
"@jedmao/location": "^3.0.0", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@testing-library/react": "^11.2.7", | ||
"@types/jest": "^26.0.23", | ||
"@types/react": "^17.0.5", | ||
"@types/react-dom": "^17.0.5", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
"@typescript-eslint/parser": "^4.23.0", | ||
"commitlint": "^12.1.4", | ||
"conventional-changelog-evelyn": "^1.2.2", | ||
"eslint": "^7.26.0", | ||
"eslint-plugin-evelyn": "^4.0.0", | ||
"eslint-plugin-import": "^2.23.2", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-regexp": "^0.10.0", | ||
"eslint-plugin-testing-library": "^4.4.0", | ||
"eslint-plugin-unicorn": "^23.0.0", | ||
"husky": "^6.0.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^11.0.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"semantic-release": "^17.4.3", | ||
"sort-package-json": "^1.50.0", | ||
"ts-jest": "^26.5.6", | ||
"typescript": "^4.2.4" | ||
"@semantic-release/changelog": "^6.0.1", | ||
"@semantic-release/git": "^10.0.1", | ||
"@testing-library/react": "^13.3.0", | ||
"@types/jest": "^28.1.7", | ||
"@types/react": "^18.0.17", | ||
"@types/react-dom": "^18.0.6", | ||
"commitlint": "^17.0.3", | ||
"conventional-changelog-evelyn": "^1.3.1", | ||
"eslint": "^8.22.0", | ||
"eslint-plugin-evelyn": "^8.1.0", | ||
"husky": "^8.0.1", | ||
"jest": "^28.1.3", | ||
"jest-environment-jsdom": "^28.1.3", | ||
"lint-staged": "^13.0.3", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"semantic-release": "^19.0.3", | ||
"sort-package-json": "^1.57.0", | ||
"ts-jest": "^28.0.8", | ||
"typescript": "^4.7.4" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
}, | ||
"release": { | ||
"extends": "conventional-changelog-evelyn/release.config.js" | ||
} | ||
} |
@@ -42,4 +42,6 @@ <div align="center"> | ||
```tsx | ||
import React from "react"; | ||
export const ExampleContext = React.createContext(false); | ||
export const ExampleComponent: React.FC = ({children}) => { | ||
export const ExampleComponent: React.FC<{children: React.ReactNode}> = ({children}) => { | ||
return ( | ||
@@ -59,3 +61,3 @@ <TestContext.Provider value={true}> | ||
import {createContextThief} from "context-thief"; | ||
import {ExampleContext, ExampleComponent} from "./example-component" | ||
import {ExampleContext, ExampleComponent} from "./example-component"; | ||
@@ -62,0 +64,0 @@ it("should have the default current context value", () => { |
21
51
82
7128