lucid-ui
Version:
A UI component library from AppNexus.
66 lines (64 loc) • 2.33 kB
JavaScript
import _has from "lodash/has";
import _forEach from "lodash/forEach";
import _noop from "lodash/noop";
import assert from 'assert';
import React from 'react';
import { shallow } from 'enzyme';
import { common } from '../../util/generic-tests';
import CheckboxLabeled from './CheckboxLabeled';
import Checkbox from '../Checkbox/Checkbox';
describe('CheckboxLabeled', function () {
common(CheckboxLabeled);
describe('props', function () {
describe('isDisabled', function () {
it('passes the value through to its `Checkbox` instance.', function () {
var wrapper = shallow( /*#__PURE__*/React.createElement(CheckboxLabeled, {
isDisabled: true
}));
assert.equal(wrapper.find(Checkbox).prop('isDisabled'), true);
});
});
describe('isSelected', function () {
it('passes the value through to its `Checkbox` instance.', function () {
var wrapper = shallow( /*#__PURE__*/React.createElement(CheckboxLabeled, {
isSelected: true
}));
assert.equal(wrapper.find(Checkbox).prop('isSelected'), true);
});
});
describe('onSelect', function () {
it('passes the value through to its `Checkbox` instance.', function () {
var foo = function foo() {
return null;
};
var wrapper = shallow( /*#__PURE__*/React.createElement(CheckboxLabeled, {
onSelect: foo
}));
assert.equal(wrapper.find(Checkbox).prop('onSelect'), foo);
});
});
describe('pass throughs', function () {
it('passes through all props not defined in `propTypes` to its `Checkbox` instance.', function () {
var wrapper = shallow( /*#__PURE__*/React.createElement(CheckboxLabeled, {
className: "wut",
isDisabled: true,
isSelected: true,
style: {
fontWeight: 'bold'
},
onSelect: _noop,
foo: 1,
bar: 2,
baz: 3,
qux: 4,
quux: 5
}));
var checkboxProps = wrapper.find(Checkbox).props(); // It should pass `foo`, `bar`, `baz`, `qux`, and `quux` through
// to the `Checkbox` instance.
_forEach(['foo', 'bar', 'baz', 'qux', 'quux'], function (prop) {
assert(_has(checkboxProps, prop));
});
});
});
});
});