Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Oct 13, 2021
1 parent 2abe025 commit 22f2bde
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/ColumnsBlock/ColumnVariations.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-intl-redux';

import ColumnVariations from './ColumnVariations';

const mockStore = configureStore();

test('renders column variations component', () => {
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
});

const component = renderer.create(
<Provider store={store}>
<ColumnVariations
id="column-variations"
title="Column variations"
fieldSet="default"
variants={[
{
icon: {},
defaultData: {
gridSize: 12,
gridCols: ['halfWidth', 'halfWidth'],
},
common: true,
title: '50 / 50',
},
]}
onChange={() => {}}
onClick={() => {}}
/>
</Provider>,
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
43 changes: 43 additions & 0 deletions src/ColumnsBlock/__snapshots__/ColumnVariations.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders column variations component 1`] = `
<div
className="ui segment"
>
<h4>
Select layout:
</h4>
<div
className="ui centered seven cards"
>
<a
className="ui card"
onClick={[Function]}
>
<div
className="content"
>
<svg
className="icon"
dangerouslySetInnerHTML={
Object {
"__html": undefined,
}
}
onClick={null}
style={
Object {
"fill": "currentColor",
"height": "55px",
"width": "auto",
}
}
/>
<p>
50 / 50
</p>
</div>
</a>
</div>
</div>
`;
32 changes: 32 additions & 0 deletions src/Widgets/QuadSize.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-intl-redux';

import QuadSize from './QuadSize';

const mockStore = configureStore();

test('renders a quad size widget component', () => {
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
});

const component = renderer.create(
<Provider store={store}>
<QuadSize
id="quadsize-widget"
title="QuadSize Widget"
fieldSet="default"
onChange={() => {}}
onBlur={() => {}}
onClick={() => {}}
/>
</Provider>,
);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
58 changes: 58 additions & 0 deletions src/Widgets/__snapshots__/QuadSize.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a quad size widget component 1`] = `
<div
className="inline field field-wrapper-quadsize-widget"
>
<div
className="ui grid"
>
<div
className="stretched row"
>
<div
className="four wide column"
>
<div
className="wrapper"
>
<label
htmlFor="field-quadsize-widget"
id="fieldset-default-field-label-quadsize-widget"
>
QuadSize Widget
</label>
</div>
</div>
<div
className="eight wide column"
>
<div
className="mocked-choices-widget"
id="mocked-field-quadsize-widget-unit"
>
Unit
-
No description
</div>
<div
className="mocked-default-widget"
id="mocked-field-quadsize-widget-slider"
>
Size
-
No description
</div>
<div
className="mocked-boolean-widget"
id="mocked-field-quadsize-widget-lockSize"
>
Customize
-
No description
</div>
</div>
</div>
</div>
</div>
`;

0 comments on commit 22f2bde

Please sign in to comment.