Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (function stringify(val, opts, pad) {
opts = opts || {};
opts.indent = opts.indent || '\t';
pad = pad || '';
/* monkey-patch do */
if (isReact(val)) {
return decompile(val);
}
/* end */
if (val === null ||
val === undefined ||
typeof val === 'number' ||
typeof val === 'boolean' ||
typeof val === 'function' ||
isRegexp(val)) {
return String(val);
}
if (val instanceof Date) {
return 'new Date(\'' + val.toISOString() + '\')';
}
it('Component should render as React DOM node', () => {
expect(TestUtils.isElement()).toBeTruthy();
});
});
test('should be able to defined arity and initial props', function (t) {
function MyComponent (props) {
return <div>{props.foo}{props.bar}{props.baz}{props.a}</div>;
}
const Curried = curryRight(MyComponent, 2, { a: 1 });
const Curried2 = Curried({ bar: 'bar' });
const Curried3 = Curried2({ baz: 'baz' });
const actual = React.createElement(Curried3, { foo: 'foo' });
t.true(isElement(actual));
const expected = React.createElement(MyComponent, {
a: 1,
foo: 'foo',
bar: 'bar',
baz: 'baz'
});
isEqual(t, actual, expected);
});
it('is React Element', () => {
expect(TestUtils.isElement()).toEqual(true)
})
it('should render a custom weekday element', () => {
const CustomWeekday = ({ className, weekday }) =>
<div>{weekday}</div>;
CustomWeekday.propTypes = { className: PropTypes.string, weekday: PropTypes.number };
const weekday = ;
const dayPicker = ;
const wrapper = mount(dayPicker);
expect(isElement(dayPicker.props.weekdayElement)).to.be.true;
expect(wrapper.containsMatchingElement(weekday)).to.be.true;
expect(wrapper.find('.DayPicker-Weekday')).to.have.length(7);
const weekdayDoms = wrapper.find('.DayPicker-Weekday');
weekdayDoms.forEach((_, i) => {
expect(weekdayDoms.at(i)).to.have.text(i);
});
});
it('should not render the outside days', () => {
bar: React.PropTypes.string.isRequired,
baz: React.PropTypes.string
},
render () {
const props = this.props;
return <div>{props.foo}{props.bar}{props.baz}</div>;
}
});
const Curried = curry(MyComponent);
const Partial1 = Curried({ foo: 'foo' });
const Partial2 = Partial1({ baz: 'baz' });
const Partial3 = Partial2({ bar: 'bar' });
const actual = React.createElement(Partial3, { foo: 'override' });
t.true(isElement(actual));
const expected = React.createElement(MyComponent, {
foo: 'override',
bar: 'bar',
baz: 'baz'
});
isEqual(t, actual, expected);
});
xit('should render array input', () => {
let FieldType = renderFieldType({
name: 'array',
type: 'array'
});
let div = TestUtils.findRenderedDOMComponentWithClass(
FieldType, 'properties-field'
);
expect(TestUtils.isElement(FieldType)).toBeFalsy();
});
const formatReactComponents = (defaultFormatter, jumpingLine, seen, deepness) => (value) => {
if (seen.indexOf(value) > -1) {
return '[Circular]';
}
if (Array.isArray(value) && value.some(isReact)) {
return formatReactArray(defaultFormatter, seen.concat([value]), deepness)(value);
}
if (typeof value === 'object' && !Array.isArray(value) && value !== null && hasAnyReactValues(value)) {
return formatReactObject(defaultFormatter, seen.concat([value]), deepness)(value);
}
if (isReact(value)) {
return formatReactValue(value, jumpingLine);
}
return defaultFormatter(value);
}
const hasAnyReactValues = (object) => {
for (let key in object) {
if (isReact(object[key])) return true;
}
return false;
}