UNPKG

enzyme-context

Version:

Enzyme Context is a pluggable library which simplifies the process of testing components that rely on react context.

36 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createShallow = exports.createMount = void 0; var enzyme_1 = require("enzyme"); var Utils_1 = require("./Utils"); /** * Creates a specialized enzyme mount() function with context set up. * * @param plugins an object where the keys are names of your choice and the values are `enzyme-context` [`MountPlugin`](https://github.com/trialspark/enzyme-context/blob/007022a7bddb7e843a27563f7918276af2ebb707/packages/enzyme-context-utils/src/Types.ts#L4-L12)s. */ function createMount(plugins) { function mount(node, options) { var pluginResults = (0, Utils_1.executePlugins)(plugins, node, options || {}); var component = (0, enzyme_1.mount)(pluginResults.node, pluginResults.options); (0, Utils_1.hookIntoLifecycle)(pluginResults, component); return (0, Utils_1.decorateEnzymeWrapper)(component, pluginResults); } return mount; } exports.createMount = createMount; /** * Creates a specialized enzyme shallow() function with context set up. * * @param plugins an object where the keys are names of your choice and the values are `enzyme-context` [`MountPlugin`](https://github.com/trialspark/enzyme-context/blob/007022a7bddb7e843a27563f7918276af2ebb707/packages/enzyme-context-utils/src/Types.ts#L4-L12)s. */ function createShallow(plugins) { function shallow(node, options) { var pluginResults = (0, Utils_1.executePlugins)(plugins, node, options || {}); var component = (0, enzyme_1.shallow)(pluginResults.node, pluginResults.options); (0, Utils_1.hookIntoLifecycle)(pluginResults, component); return (0, Utils_1.decorateEnzymeWrapper)(component, pluginResults); } return shallow; } exports.createShallow = createShallow; //# sourceMappingURL=index.js.map