Javascript 酶与环境反应的检测
在酶测试套件中测试使用Context.Consumer的React组件时运气不佳 侧包装器组件:Javascript 酶与环境反应的检测,javascript,reactjs,testing,mocha.js,enzyme,Javascript,Reactjs,Testing,Mocha.js,Enzyme,在酶测试套件中测试使用Context.Consumer的React组件时运气不佳 侧包装器组件: const SidebarWrapper = props => ( <SidebarContext.Consumer> {({ sidebar: { Component, isOpen, close } }) => ( <OnOutsideClick onClick={event =&g
const SidebarWrapper = props => (
<SidebarContext.Consumer>
{({ sidebar: { Component, isOpen, close } }) => (
<OnOutsideClick
onClick={event => {
/* this class is added to hamburger menu to avoid opening + closing at the same time */
if (!event.target.className.includes("override-outside-click")) {
close();
}
}}
>
<div className={classNames("sidebar", { "sidebar--open": isOpen })}>
<Component />
</div>
</OnOutsideClick>
)}
</SidebarContext.Consumer>
);
你知道怎么让它工作吗
describe("<SidebarWrapper />", () => {
it("test", () => {
const app = mount
(
<SidebarWrapper />
);
expect(app.find(".sidebar"));
});
});
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"react": "^16.8.4",
"react-dom": "^16.8.4"