@orfeas126/box-ui-elements
Version:
Box UI Elements
43 lines (41 loc) • 1.5 kB
JavaScript
import * as React from 'react';
import { mount } from 'enzyme';
import { withFeatureProvider } from '..';
describe('withFeatureProvider HOC', () => {
test('wraps component with FeatureProvider', () => {
const MyComponent = () => <div />;
const featureProp = { foo: true };
const otherProps = { bar: true, baz: false };
const WrapperComponent = withFeatureProvider(MyComponent);
const container = mount(<WrapperComponent features={featureProp} {...otherProps} />);
expect(container).toMatchInlineSnapshot(`
<ForwardRef(withFeatureProvider(MyComponent))
bar={true}
baz={false}
features={
{
"foo": true,
}
}
>
<FeatureProvider
features={
{
"foo": true,
}
}
>
<MyComponent
bar={true}
baz={false}
>
<div />
</MyComponent>
</FeatureProvider>
</ForwardRef(withFeatureProvider(MyComponent))>
`);
expect(container.find('ForwardRef(withFeatureProvider(MyComponent))')).toHaveLength(1);
expect(container.find('FeatureProvider').props().features).toEqual(featureProp);
expect(container.find('MyComponent').props()).toEqual(otherProps);
});
});