Skip to content

Commit

Permalink
fix: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hvolschenk committed Nov 22, 2017
1 parent 6031975 commit 7d02f97
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/cell.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { shallow } from 'enzyme';
import React from 'react';

import Cell from './cell';

test('Cell > Adds default classNames', () => {
const wrapper = shallow(<Cell />, { disableLifecycleMethods: true });
const expected = 'mdc-layout-grid__cell';

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});

test('Cell > Adds all classNames based on props', () => {
const ALIGN = 'bottom';
const CLASS_NAME = 'CLASS_NAME';
const COLUMNS = 12;
const DESKTOP = 12;
const PHONE = 4;
const TABLET = 8;
const wrapper = shallow(
<Cell
align={ALIGN}
className={CLASS_NAME}
columns={COLUMNS}
desktop={DESKTOP}
phone={PHONE}
tablet={TABLET}
/>,
{ disableLifecycleMethods: true },
);
const expected = `mdc-layout-grid__cell ${CLASS_NAME} mdc-layout-grid__cell--align-${ALIGN} ` +
`mdc-layout-grid__cell--span-${COLUMNS} mdc-layout-grid__cell--span-${DESKTOP}-desktop ` +
`mdc-layout-grid__cell--span-${PHONE}-phone mdc-layout-grid__cell--span-${TABLET}-tablet`;

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});
29 changes: 29 additions & 0 deletions src/grid.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { shallow } from 'enzyme';
import React from 'react';

import Grid from './grid';

const CHILDREN = <p>CHILDREN</p>;

test('Grid > Adds the default classNames', () => {
const wrapper = shallow(<Grid>{CHILDREN}</Grid>, { disableLifecycleMethods: true });
const expected = 'mdc-layout-grid';

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});

test('Grid > Adds all classNames based on props', () => {
const ALIGN = 'left';
const CLASS_NAME = 'CLASS_NAME';
const wrapper = shallow(
<Grid align={ALIGN} className={CLASS_NAME}>{CHILDREN}</Grid>,
{ disableLifecycleMethods: true },
);
const expected = `mdc-layout-grid mdc-layout-grid--align-${ALIGN} ${CLASS_NAME}`;

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});
28 changes: 28 additions & 0 deletions src/row.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { shallow } from 'enzyme';
import React from 'react';

import Row from './row';

const CHILDREN = <p>CHILDREN</p>;

test('Row > Adds the default classNames', () => {
const wrapper = shallow(<Row>{CHILDREN}</Row>, { disableLifecycleMethods: true });
const expected = 'mdc-layout-grid__inner';

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});

test('Row > Adds all classNames based on props', () => {
const CLASS_NAME = 'CLASS_NAME';
const wrapper = shallow(
<Row className={CLASS_NAME}>{CHILDREN}</Row>,
{ disableLifecycleMethods: true },
);
const expected = `mdc-layout-grid__inner ${CLASS_NAME}`;

const actual = wrapper.props().className;

expect(actual).toBe(expected);
});

0 comments on commit 7d02f97

Please sign in to comment.