wix-style-react
Version:
wix-style-react
37 lines (31 loc) • 1.16 kB
JavaScript
import React from 'react';
import { mount } from 'enzyme';
import Collapse from '.';
describe('Collapse', function () {
it('should render children', function () {
var wrapper = mount(React.createElement(Collapse, { children: 'hello' }));
expect(wrapper.text()).toEqual('hello');
});
describe('`open` prop', function () {
it('should not render children when false', function () {
var wrapper = mount(React.createElement(Collapse, { open: false, children: 'hello' }));
expect(wrapper.children().text()).toEqual(null);
});
});
describe('`dataHook` prop', function () {
it('should be passed to children', function () {
var hookForRoot = "I'm Hooked!";
var hookOfChild = 'Leave britney alone!';
var wrapper = mount(React.createElement(Collapse, {
dataHook: hookForRoot,
children: React.createElement(
'div',
{ 'data-hook': hookOfChild },
'arbitrary content'
)
}));
expect(wrapper.children().prop('data-hook')).toEqual(hookForRoot);
expect(wrapper.find('[data-hook="' + hookOfChild + '"]').exists()).toBe(true);
});
});
});