Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
John Benavides committed Jul 3, 2018
1 parent a478040 commit 19f3c2b
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 382 deletions.
2 changes: 1 addition & 1 deletion src/components/box/__test__/__snapshots__/box.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`Box component Should accept a react Element as renderAs prop 1`] = `
className="box"
style={Object {}}
>
Custom
Custom
This should be a p element
</p>
`;
Expand Down
2 changes: 1 addition & 1 deletion src/components/box/__test__/box.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Custom
</p>
);

Custom.propTypes = { children: PropTypes.element.isRequired };
Custom.propTypes = { children: PropTypes.node.isRequired };

const component = renderer.create(
<Box renderAs={Custom}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,6 @@ exports[`Breadcrumb component Should be a Breadcrumb 1`] = `
</nav>
`;

exports[`Breadcrumb component Should throw a warning that hrefAttr is not defined 1`] = `
<nav
className="breadcrumb"
style={Object {}}
>
<ul>
<li
className=""
>
<a
className="Others"
null="/"
>
Home
</a>
</li>
<li
className=""
>
<a
className="Others"
null="/section"
>
Section
</a>
</li>
<li
className="is-active"
>
<a
className="Others"
null="/detail"
>
Details
</a>
</li>
</ul>
</nav>
`;

exports[`Breadcrumb component Should use inline style and custom size 1`] = `
<nav
className="breadcrumb is-large"
Expand Down
41 changes: 0 additions & 41 deletions src/components/breadcrumb/__test__/breadcrumb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@ import React from 'react';
import renderer from 'react-test-renderer';
import Breadcrumb from '..';

/* eslint-disable react/prop-types */
const Anchor = ({
children,
...props
}) => (
<a className="Others" {...props}>
{children}
</a>
);
/* eslint-enable react/prop-types */

describe('Breadcrumb component', () => {
beforeEach(() => {
// eslint-disable-next-line no-console
console.warn = jest.genMockFn();
});
afterAll(() => {
// eslint-disable-next-line no-console
console.warn.mockRestore();
});
it('Should be a Breadcrumb', () => {
const component = renderer.create(<Breadcrumb
items={[
Expand Down Expand Up @@ -63,28 +44,6 @@ describe('Breadcrumb component', () => {
expect(component.toJSON()).toMatchSnapshot();
})
));
it('Should throw a warning that hrefAttr is not defined', () => {
const component = renderer.create(<Breadcrumb
renderAs={Anchor}
items={[
{
url: '/',
name: 'Home',
},
{
url: '/section',
name: 'Section',
},
{
url: '/detail',
name: 'Details',
active: true,
},
]}
/>);
expect(global.console.warn).toBeCalled();
expect(component.toJSON()).toMatchSnapshot();
});
it('Should use inline style and custom size', () => {
const component = renderer.create(<Breadcrumb
style={{ marginTop: 10 }}
Expand Down
4 changes: 0 additions & 4 deletions src/components/breadcrumb/breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export default class Breadcrumb extends PureComponent {
align,
...props
} = this.props;
if (renderAs !== 'a' && !hrefAttr) {
// eslint-disable-next-line no-console
console.warn('if renderAs is different the anchor (a), hrefAttr is required. Check Breadcrumb props');
}
const Element = renderAs;
return (
<nav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ exports[`Button component Should render be disabled 1`] = `
<button
className="button"
disabled={true}
onClick={undefined}
style={Object {}}
tabIndex={-1}
/>
Expand Down
18 changes: 0 additions & 18 deletions src/components/card/__test__/__snapshots__/card.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,3 @@ exports[`Card component Should have card-image classname 1`] = `
</figure>
</div>
`;

exports[`Card component Should print deprecation warning 1`] = `
<div
className="card-image"
style={Object {}}
>
<figure
className="image is-4by3"
style={Object {}}
>
<img
alt=""
onError={[Function]}
src="http://bulma.io/images/placeholders/1280x960.png"
/>
</figure>
</div>
`;
9 changes: 0 additions & 9 deletions src/components/card/__test__/card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,4 @@ Content
);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should print deprecation warning', () => {
// eslint-disable-next-line no-console
console.warn = jest.genMockFn();
const component = renderer.create(<Card type="image" size="4by3" src="http://bulma.io/images/placeholders/1280x960.png" />);
expect(component.toJSON()).toMatchSnapshot();
expect(global.console.warn).toBeCalled();
// eslint-disable-next-line no-console
console.warn.mockRestore();
});
});
19 changes: 2 additions & 17 deletions src/components/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,27 @@ export default class Card extends PureComponent {
children: PropTypes.node,
style: PropTypes.shape({}),
renderAs: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* @deprecated please use Card.Header, Card.Content, Card.Footer instead
*/
type: PropTypes.oneOf(['header', 'header-item', 'header-icon', 'footer', 'footer-item', 'image', 'content']),
}

static defaultProps = {
className: '',
children: null,
style: {},
type: null,
renderAs: 'div',
}

render() {
const {
className,
children,
type,
renderAs,
...props
} = this.props;
if (type) {
// eslint-disable-next-line no-console
console.warn('Deprecation Warning: Prop type is deprecated and will be removed on future release, please use Card.Header, Card.Content and Card.Footer elements instead');
}
if (type === 'image') {
return <CardImage {...props} className={className} />;
}

const Element = renderAs;
return (
<Element
className={classnames(className, {
[`card-${type}`]: type,
card: !type,
})}
className={classnames('card', className)}
{...props}
>
{children}
Expand Down
32 changes: 0 additions & 32 deletions src/components/columns/__test__/__snapshots__/columns.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,3 @@ exports[`Columns component Should have columns one column half width, other narr
</div>
</div>
`;

exports[`Columns component Should have throw warning if deprecated prop is used but render it anyway 1`] = `
<div
className="columns is-multiline"
style={Object {}}
>
<div
className="column is-half-mobile"
style={Object {}}
>
1
</div>
<div
className="column is-narrow"
style={Object {}}
>
2
</div>
<div
className="column"
style={Object {}}
>
3
</div>
<div
className="column"
style={Object {}}
>
4
</div>
</div>
`;
85 changes: 10 additions & 75 deletions src/components/columns/components/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,6 @@ export default class Column extends PureComponent {
offset: PropTypes.oneOf(sizes),
narrow: PropTypes.bool,
}),
/**
* @deprecated Please use mobile.size prop
*/
mobileSize: PropTypes.oneOf(sizes),

/**
* @deprecated Please use table.size prop
*/
tabletSize: PropTypes.oneOf(sizes),
/**
* @deprecated Please use desktop.size prop
*/
desktopSize: PropTypes.oneOf(sizes),
/**
* @deprecated Please use widescreen.size prop
*/
widescreenSize: PropTypes.oneOf(sizes),
/**
* @deprecated Please use fullhd.size prop
*/
fullhdSize: PropTypes.oneOf(sizes),
/**
* @deprecated Please use mobile.offset prop
*/
mobileOffset: PropTypes.oneOf(sizes),
/**
* @deprecated Please use tablet.offset prop
*/
tabletOffset: PropTypes.oneOf(sizes),
/**
* @deprecated Please use desktop.offset prop
*/
desktopOffset: PropTypes.oneOf(sizes),
/**
* @deprecated Please use widescreen.offset prop
*/
widescreenOffset: PropTypes.oneOf(sizes),
/**
* @deprecated Please use fullhd.offset prop
*/
fullhdOffset: PropTypes.oneOf(sizes),
}

static defaultProps = {
Expand Down Expand Up @@ -140,16 +99,6 @@ export default class Column extends PureComponent {
offset: null,
narrow: false,
},
mobileSize: null,
tabletSize: null,
desktopSize: null,
widescreenSize: null,
fullhdSize: null,
mobileOffset: null,
tabletOffset: null,
desktopOffset: null,
widescreenOffset: null,
fullhdOffset: null,
}

render() {
Expand All @@ -164,39 +113,25 @@ export default class Column extends PureComponent {
desktop,
widescreen,
fullhd,
mobileSize,
tabletSize,
desktopSize,
widescreenSize,
fullhdSize,
mobileOffset,
tabletOffset,
desktopOffset,
widescreenOffset,
fullhdOffset,
...props
} = this.props;

if (mobileSize || tabletSize || desktopSize || widescreenSize || fullhdSize || mobileOffset || tabletOffset || desktopOffset || widescreenOffset || fullhdOffset) {
// eslint-disable-next-line no-console
console.warn('DEPRECATION Warning: The props: mobileSize tabletSize desktopSize widescreenSize fullhdSize mobileOffset tabletOffset desktopOffset widescreenOffset fullhdOffset are deprecated, please use the mobile.size... alternatives');
}

return (
<div
{...props}
className={classNames(className, 'column', {
[`is-${size}`]: size,
[`is-${mobile.size || mobileSize}-mobile`]: mobile.size || mobileSize,
[`is-${tablet.size || tabletSize}-tablet`]: tablet.size || tabletSize,
[`is-${desktop.size || desktopSize}-desktop`]: desktop.size || desktopSize,
[`is-${widescreen.size || widescreenSize}-widescreen`]: widescreen.size || widescreenSize,
[`is-${fullhd.size || fullhdSize}-fullhd`]: fullhd.size || fullhdSize,
[`is-offset-${mobile.offset || mobileOffset}-mobile`]: mobile.offset || mobileOffset,
[`is-offset-${tablet.offset || tabletOffset}-tablet`]: tablet.offset || tabletOffset,
[`is-offset-${desktop.offset || desktopOffset}-desktop`]: desktop.offset || desktopOffset,
[`is-offset-${widescreen.offset || widescreenOffset}-widescreen`]: widescreen.offset || widescreenOffset,
[`is-offset-${fullhd.offset || fullhdOffset}-fullhd`]: fullhd.offset || fullhdOffset,
[`is-${mobile.size}-mobile`]: mobile.size,
[`is-${tablet.size}-tablet`]: tablet.size,
[`is-${desktop.size}-desktop`]: desktop.size,
[`is-${widescreen.size}-widescreen`]: widescreen.size,
[`is-${fullhd.size}-fullhd`]: fullhd.size,
[`is-offset-${mobile.offset}-mobile`]: mobile.offset,
[`is-offset-${tablet.offset}-tablet`]: tablet.offset,
[`is-offset-${desktop.offset}-desktop`]: desktop.offset,
[`is-offset-${widescreen.offset}-widescreen`]: widescreen.offset,
[`is-offset-${fullhd.offset}-fullhd`]: fullhd.offset,
[`is-offset-${offset}`]: offset,
'is-narrow': narrow,
'is-narrow-mobile': mobile.narrow,
Expand Down
Loading

0 comments on commit 19f3c2b

Please sign in to comment.