Skip to content

Commit

Permalink
Test Renderer from Startujici component.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivosh committed Feb 22, 2018
1 parent dcb8fc1 commit c389198
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ui/src/registrator/Startujici/Startujici.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import StartujiciProTypContainer from '../../shared/StartujiciProTyp/StartujiciP
import './Startujici.css';

// eslint-disable-next-line no-confusing-arrow
const Renderer = ({ id, startCislo, dokonceno }) =>
export const Renderer = ({ id, startCislo, dokonceno }) =>
id ? (
<NavLink
to={`/prihlasky/${id}`}
Expand Down
23 changes: 22 additions & 1 deletion ui/src/registrator/Startujici/Startujici.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import moment from 'moment';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import toJSON from 'enzyme-to-json';
import Startujici, { Legenda } from './Startujici';
import StartujiciProTyp from '../../shared/StartujiciProTyp/StartujiciProTyp';
import Startujici, { Legenda, Renderer } from './Startujici';

it('renders Startujici', () => {
const typy = ['maraton', 'půlmaraton', 'cyklo', 'koloběžka'];
Expand All @@ -14,3 +17,21 @@ it('renders Legenda', () => {
const component = renderer.create(<Legenda />);
expect(component.toJSON()).toMatchSnapshot();
});

it('Renderer', () => {
const startujici = [
{
id: '10',
startCislo: 7,
dokonceno: true,
duration: moment.duration('PT4H15M32.45S')
}
];

const component = renderer.create(
<MemoryRouter>
<StartujiciProTyp startujici={startujici} renderer={Renderer} />
</MemoryRouter>
);
expect(component.toJSON()).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Renderer 1`] = `
<div
className="StartujiciProTyp-grid"
>
<a
aria-current={false}
className="StartujiciProTyp-item Startujici-dokonceno"
href="/prihlasky/10"
onClick={[Function]}
style={undefined}
>
7
</a>
</div>
`;

exports[`renders Legenda 1`] = `
<div
className="Startujici_legenda"
Expand Down
21 changes: 7 additions & 14 deletions ui/src/shared/StartujiciProTyp/StartujiciProTyp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ it('jeden startující', () => {
id: '10',
startCislo: 7,
dokonceno: true,
duration: moment.duration('PT4H15M32.45S'),
onClick: jest.fn()
duration: moment.duration('PT4H15M32.45S')
}
];

Expand All @@ -43,23 +42,20 @@ it('třináct startujících', () => {
id: '10',
startCislo: 16,
dokonceno: true,
duration: moment.duration('PT4H15M32.45S'),
onClick: jest.fn()
duration: moment.duration('PT4H15M32.45S')
},
{ id: '2', startCislo: 25, dokonceno: false },
{
id: '3',
startCislo: 9,
dokonceno: true,
duration: moment.duration('PT2H17M29.14S'),
onClick: jest.fn()
duration: moment.duration('PT2H17M29.14S')
},
{
id: '12',
startCislo: 15,
dokonceno: true,
duration: moment.duration('PT3H59M59.01S'),
onClick: jest.fn()
duration: moment.duration('PT3H59M59.01S')
},
{ id: '9', startCislo: 1, dokonceno: false },
{ id: '29', startCislo: 8, dokonceno: null },
Expand All @@ -70,16 +66,14 @@ it('třináct startujících', () => {
id: '10',
startCislo: 33,
dokonceno: true,
duration: moment.duration('PT3H30M22.45S'),
onClick: jest.fn()
duration: moment.duration('PT3H30M22.45S')
},
{ id: '7', startCislo: 21, dokonceno: false },
{
id: '13',
startCislo: 24,
dokonceno: true,
duration: moment.duration('PT3H33M14.15S'),
onClick: jest.fn()
duration: moment.duration('PT3H33M14.15S')
},
{ id: '34', startCislo: 27, dokonceno: null },
{ id: '14', startCislo: 22, dokonceno: null },
Expand All @@ -88,8 +82,7 @@ it('třináct startujících', () => {
id: '15',
startCislo: 23,
dokonceno: true,
duration: moment.duration('PT3H27M42.38S'),
onClick: jest.fn()
duration: moment.duration('PT3H27M42.38S')
},
{ id: '59', startCislo: 26, dokonceno: null }
];
Expand Down

0 comments on commit c389198

Please sign in to comment.