import React from 'react';
import Enzyme, { shallow, mount } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import Panel, { PanelConsumer } from '../Panel';
Enzyme.configure({ adapter: new Adapter() });
describe('Panel', () => {
it('expect to render', () => {
const wrapper = shallow(
Hello content
);
expect(wrapper).toMatchSnapshot();
});
it('expect to render with custom className', () => {
const props = {
className: 'ais-Panel-Breadcrumb',
};
const wrapper = shallow(
Hello content
);
expect(wrapper).toMatchSnapshot();
});
it('expect to render without refinement', () => {
const wrapper = shallow(
Hello content
);
wrapper.setState({ canRefine: false });
expect(wrapper).toMatchSnapshot();
});
it('expect to render with header', () => {
const props = {
header:
Header
,
};
const wrapper = shallow(
Hello content
);
expect(wrapper).toMatchSnapshot();
});
it('expect to render with footer', () => {
const props = {
footer: Footer
,
};
const wrapper = shallow(
Hello content
);
expect(wrapper).toMatchSnapshot();
});
it('expect to expose context to its children', () => {
let provided;
const wrapper = mount(
{(setCanRefine) => {
provided = setCanRefine;
return null;
}}
);
expect(provided).toEqual(wrapper.instance().setCanRefine);
});
it('expect to render when setCanRefine is called', () => {
const wrapper = mount(
{(setCanRefine) => (
)}
);
expect(wrapper.state('canRefine')).toBe(true);
expect(wrapper).toMatchSnapshot();
// Simulate context call
wrapper.find('button').simulate('click');
expect(wrapper.state('canRefine')).toBe(false);
expect(wrapper).toMatchSnapshot();
});
});