Skip to content

Commit

Permalink
Added tests for mosaic components.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Apr 12, 2017
1 parent 842267e commit e1051d0
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 63 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Plone in React
[![Coverage](https://img.shields.io/coveralls/plone/plone-react.svg)](https://coveralls.io/github/plone/plone-react)
[![Dependencies](https://img.shields.io/david/plone/plone-react.svg)](https://github.com/plone/plone-react/blob/master/package.json)
[![Dev Dependencies](https://img.shields.io/david/dev/plone/plone-react.svg)](https://github.com/plone/plone-react/blob/master/package.json)
[![Node version](https://img.shields.io/badge/node-6.9.1-brightgreen.svg)](https://github.com/plone/plone-react/blob/master/.nvmrc)
[![License](https://img.shields.io/github/license/plone/plone-react.svg)](https://github.com/plone/plone-react/blob/master/LICENCE.md)

## Installation
Expand Down Expand Up @@ -52,7 +51,7 @@ If chromedriver could not be found, make sure to update with:
### License

The BSD 3-Clause License. Copyrights hold the Plone Foundation.
See [LICENSE.rst](LICENSE.rst) for details.
See [LICENSE.md](LICENSE.md) for details.

### Todo
* Redirect after SSR edit and add content
Expand Down
1 change: 0 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* @example import { Field } from 'components';
*/

export Editor from './mosaic/Editor/Editor';
export Grid from './mosaic/Grid/Grid';
export Layout from './mosaic/Layout/Layout';
export Row from './mosaic/Row/Row';
Expand Down
60 changes: 0 additions & 60 deletions src/components/mosaic/Editor/Editor.jsx

This file was deleted.

21 changes: 21 additions & 0 deletions src/components/mosaic/Grid/Grid.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Grid from './Grid';

jest.mock('../Row/Row',
() => jest.fn(() => <div />));

test('renders a grid component', () => {
const component = renderer.create(
<Grid
rows={[
['cell 1.1', 'cell 1.2'],
['cell 2.1', 'cell 2.2'],
]}
selectTile={() => {}}
setTileContent={() => {}}
/>
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
10 changes: 10 additions & 0 deletions src/components/mosaic/Grid/__snapshots__/Grid.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a grid component 1`] = `
<div
className="grid"
>
<div />
<div />
</div>
`;
21 changes: 21 additions & 0 deletions src/components/mosaic/Row/Row.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Row from './Row';

jest.mock('../Tile/Tile',
() => jest.fn(() => <div />));

test('renders a row component', () => {
const component = renderer.create(
<Row
tiles={[{
url: 'http://localhost',
}]}
row={0}
selectTile={() => {}}
setTileContent={() => {}}
/>
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
9 changes: 9 additions & 0 deletions src/components/mosaic/Row/__snapshots__/Row.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a row component 1`] = `
<div
className="undefined row"
>
<div />
</div>
`;
23 changes: 23 additions & 0 deletions src/components/mosaic/Tile/Tile.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Tile from './Tile';

jest.mock('draft-js-editor',
() => jest.fn(() => <div />));
global.__SERVER__ = true;

test('renders a tile component', () => {
const component = renderer.create(
<Tile
content={'<h1>Hello World!</h1>'}
width={4}
row={0}
column={0}
selected={true}
selectTile={() => {}}
setTileContent={() => {}}
/>
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
12 changes: 12 additions & 0 deletions src/components/mosaic/Tile/__snapshots__/Tile.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a tile component 1`] = `
<div
className="undefined col-xs-4 undefined"
>
<div
className={undefined}
onClick={[Function]}
/>
</div>
`;

0 comments on commit e1051d0

Please sign in to comment.