UNPKG

@retailmenot/anchor

Version:

A React UI Library by RetailMeNot

29 lines 1.4 kB
// REACT import * as React from 'react'; // SUBJECT import { cloneWithProps } from './cloneWithProps'; // VENDOR import { mount } from 'enzyme'; const Component = ({ className, text, }) => React.createElement("span", { className: className }, text); describe('Util: cloneWithProps', () => { it('should clone an element.', () => { const subject = cloneWithProps(React.createElement(Component, null)); expect(mount(subject)).toBeDefined(); }); it('should include provided props.', () => { const subject = cloneWithProps(React.createElement(Component, null), { text: 'Some Text' }); expect(mount(subject).props().text).toEqual('Some Text'); }); it('should not override existing props', () => { const subject = cloneWithProps(React.createElement(Component, { text: "Existing Text" }), { text: 'Some Text', }); expect(mount(subject).props().text).toEqual('Existing Text'); }); it('should include className with existing element className', () => { const subject = cloneWithProps(React.createElement(Component, { className: "anchor-component" }), { text: 'Some Text', className: 'test-class' }); expect(mount(subject).hasClass('anchor-component')).toEqual(true); expect(mount(subject).hasClass('test-class')).toEqual(true); }); }); //# sourceMappingURL=cloneWithProps.spec.js.map