Add specs for errors, mainimage, and notice (#4453) [ci skip]

This commit is contained in:
Karin Hendrikse 2019-10-15 22:46:25 +02:00 committed by Mac Siri
parent c9c86a44ea
commit 0ff237cf20
6 changed files with 129 additions and 0 deletions

View file

@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Errors /> renders properly 1`] = `
<div
class="articleform__errors"
>
<h2>
<span
aria-label="face screaming in fear"
role="img"
>
😱
</span>
Heads up:
</h2>
<ul>
<li>
0:  Error 1
</li>
<li>
1:  Error 2
</li>
</ul>
</div>
`;

View file

@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<MainImage /> renders properly 1`] = `
<div
class="articleform__mainimage"
onClick={[MockFunction]}
>
<img
src="http://lorempixel.com/400/200/"
/>
</div>
`;

View file

@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<notice /> renders properly when published with a first version 1`] = `
<div
class="articleform__notice articleform__notice--publishing"
>
Saving ...
</div>
`;
exports[`<notice /> renders properly when published with a second version 1`] = `
<div
class="articleform__notice articleform__notice--publishing"
>
Publishing...
</div>
`;
exports[`<notice /> renders properly when unpublished with a version 1`] = `
<div
class="articleform__notice articleform__notice--draft"
>
Saving Draft...
</div>
`;
exports[`<notice /> renders properly when unpublished without a version 1`] = `
<div
class="articleform__notice articleform__notice--draft"
>
Saving ...
</div>
`;

View file

@ -0,0 +1,15 @@
import { h } from 'preact';
import render from 'preact-render-to-json';
import Errors from '../errors';
const errorsList = [
'Error 1',
'Error 2'
];
describe('<Errors />', () => {
it('renders properly', () => {
const tree = render(<Errors errorsList={errorsList} />);
expect(tree).toMatchSnapshot();
});
});

View file

@ -0,0 +1,19 @@
import { h } from 'preact';
import render from 'preact-render-to-json';
import { shallow } from 'preact-render-spy';
import MainImage from '../mainImage';
describe('<MainImage />', () => {
const editHandler = jest.fn();
it('renders properly', () => {
const tree = render(<MainImage mainImage='http://lorempixel.com/400/200/' onEdit={editHandler} />);
expect(tree).toMatchSnapshot();
});
it('fires onEdit when clicked', () => {
const container = shallow(<MainImage mainImage='http://lorempixel.com/400/200/' onEdit={editHandler} />);
container.find('.articleform__mainimage').simulate('click');
expect(editHandler).toHaveBeenCalled();
});
});

View file

@ -0,0 +1,25 @@
import { h } from 'preact';
import render from 'preact-render-to-json';
import Notice from '../notice';
describe('<notice />', () => {
it('renders properly when published with a first version', () => {
const tree = render(<Notice published version='v1' />);
expect(tree).toMatchSnapshot();
});
it('renders properly when published with a second version', () => {
const tree = render(<Notice published version='v2' />);
expect(tree).toMatchSnapshot();
});
it('renders properly when unpublished without a version', () => {
const tree = render(<Notice version='' />);
expect(tree).toMatchSnapshot();
});
it('renders properly when unpublished with a version', () => {
const tree = render(<Notice version='v2' />);
expect(tree).toMatchSnapshot();
});
});