Skip to content

Commit

Permalink
Fix decreased test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethnym committed Oct 18, 2020
1 parent b3d3bb6 commit 9e74e9b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/components/table/__test__/__snapshots__/table.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ exports[`Table component Should concat classname in props with Bulma classname 1
</table>
`;

exports[`Table component Should create a scrollable table 1`] = `
<div
className="table-container"
>
<table
className="table is-fullwidth is-striped"
>
<tr />
</table>
</div>
`;

exports[`Table component Should exist 1`] = `[Function]`;

exports[`Table component Should have table classname 1`] = `
Expand Down
11 changes: 11 additions & 0 deletions src/components/table/__test__/table.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Table from '..';
import TableContainer from '../components/container';

describe('Table component', () => {
it('Should exist', () => {
Expand Down Expand Up @@ -30,4 +31,14 @@ describe('Table component', () => {
);
expect(component.toJSON()).toMatchSnapshot();
});
it('Should create a scrollable table', () => {
const component = renderer.create(
<TableContainer>
<Table>
<tr />
</Table>
</TableContainer>,
);
expect(component.toJSON()).toMatchSnapshot();
});
});
2 changes: 2 additions & 0 deletions src/modifiers/__test__/__snapshots__/modifiers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exports[`Helper proptypes Should have paddingless and clearfix classes 1`] = `"i

exports[`Helper proptypes Should have responsive modifier flex-tablet-only and block-widescreen 1`] = `"is-flex-tablet-only is-block-widescreen"`;

exports[`Helper proptypes Should have spacing helpers 1`] = `"mt-2 px-1"`;

exports[`Helper proptypes Should have text color success 1`] = `"has-text-success"`;

exports[`Helper proptypes Should have text helpers 1`] = `"has-text-success has-text-centered has-text-weight-bold is-uppercase is-italic"`;
10 changes: 10 additions & 0 deletions src/modifiers/__test__/modifiers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ describe('Helper proptypes', () => {
).toMatchSnapshot();
});

test('Should have spacing helpers', () => {
expect(
modifiers.classnames({
mx: 0,
mt: 2,
px: 1,
}),
).toMatchSnapshot();
});

test('Should have responsive modifier flex-tablet-only and block-widescreen', () => {
expect(
modifiers.classnames({
Expand Down
12 changes: 6 additions & 6 deletions src/modifiers/spacing.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import classnames from 'classnames';

const modifierNames = [
const MODIFIER_NAMES = [
'mt',
'mr',
'mb',
Expand All @@ -15,12 +15,12 @@ const modifierNames = [
'px',
'py',
];
const sizes = [0, 1, 2, 3, 4, 5, 6];
const SIZES = [0, 1, 2, 3, 4, 5, 6];

export default {
...modifierNames.reduce(
...MODIFIER_NAMES.reduce(
(props, name) => {
props.propTypes[name] = PropTypes.oneOf(sizes);
props.propTypes[name] = PropTypes.oneOf(SIZES);
props.defaultProps[name] = undefined;
return props;
},
Expand All @@ -29,15 +29,15 @@ export default {
classnames: (props) =>
classnames(
Object.keys(props).reduce((classes, propName) => {
if (modifierNames.includes(propName)) {
if (MODIFIER_NAMES.includes(propName)) {
classes[`${propName}-${props[propName]}`] = props[propName];
}
return classes;
}, {}),
),
clean: (props) =>
Object.keys(props).reduce((cleaned, propName) => {
if (!modifierNames.includes(propName)) {
if (!MODIFIER_NAMES.includes(propName)) {
cleaned[propName] = props[propName];
}
return cleaned;
Expand Down

0 comments on commit 9e74e9b

Please sign in to comment.