mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-16 13:46:16 +02:00
Set babel.
This commit is contained in:
29
src/bootstrap/__tests__/Button.test.js
Normal file
29
src/bootstrap/__tests__/Button.test.js
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import Button from '../components/Button'
|
||||
|
||||
describe('<Button />', () => {
|
||||
it('Render button correctly', () => {
|
||||
const {container} = render(<Button>Test Button</Button>);
|
||||
expect(container.firstChild).toMatchSnapshot()
|
||||
});
|
||||
|
||||
it('Render button with custom classes', () => {
|
||||
const {container} = render(<Button className="one two three">Test Button</Button>)
|
||||
expect(container.firstChild).toMatchSnapshot()
|
||||
});
|
||||
|
||||
it('Render button with spinner', () => {
|
||||
const {container} = render(<Button loading={true}>Test Button</Button>)
|
||||
expect(container.firstChild).toMatchSnapshot()
|
||||
});
|
||||
});
|
36
src/bootstrap/__tests__/Checkbox.test.js
Normal file
36
src/bootstrap/__tests__/Checkbox.test.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import Checkbox from '../components/Checkbox'
|
||||
|
||||
describe('<Checkbox/>', () => {
|
||||
it('Render checkbox', () => {
|
||||
const {container} = render(
|
||||
<Checkbox
|
||||
label="Test label"
|
||||
checked
|
||||
helpText="Some help text"
|
||||
onChange={()=>{}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Render uncheked checkbox', () => {
|
||||
const {container} = render(
|
||||
<Checkbox
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
28
src/bootstrap/__tests__/NumberInput.test.js
Normal file
28
src/bootstrap/__tests__/NumberInput.test.js
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import NumberInput from '../components/NumberInput';
|
||||
|
||||
|
||||
describe('<NumberInput/>', () => {
|
||||
it('Render number input', () => {
|
||||
const {container} = render(
|
||||
<NumberInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
value={1123}
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
27
src/bootstrap/__tests__/PasswordInput.test.js
Normal file
27
src/bootstrap/__tests__/PasswordInput.test.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import PasswordInput from '../components/PasswordInput';
|
||||
|
||||
describe('<PasswordInput/>', () => {
|
||||
it('Render password input', () => {
|
||||
const {container} = render(
|
||||
<PasswordInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
value="Some password"
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
35
src/bootstrap/__tests__/RadioSet.test.js
Normal file
35
src/bootstrap/__tests__/RadioSet.test.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import RadioSet from '../components/RadioSet';
|
||||
|
||||
const TEST_CHOICES = [
|
||||
{label: 'label', value: 'value'},
|
||||
{label: 'another label', value: 'another value'},
|
||||
{label: 'another one label', value: 'another on value'}
|
||||
];
|
||||
|
||||
describe('<RadioSet/>', () => {
|
||||
it('Render radio set', () => {
|
||||
const {container} = render(
|
||||
<RadioSet
|
||||
name={'test_name'}
|
||||
label='Radios set label'
|
||||
value='value'
|
||||
choices={TEST_CHOICES}
|
||||
helpText={'Some help text'}
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
51
src/bootstrap/__tests__/Select.test.js
Normal file
51
src/bootstrap/__tests__/Select.test.js
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {fireEvent, getByDisplayValue, getByText, render} from 'customTestRender';
|
||||
|
||||
import Select from '../components/Select';
|
||||
|
||||
const TEST_CHOICES = {
|
||||
'1': 'one',
|
||||
'2': 'two',
|
||||
'3': 'three',
|
||||
};
|
||||
|
||||
describe('<Select/>', () => {
|
||||
var selectContainer;
|
||||
const onChangeHandler = jest.fn();
|
||||
beforeEach(() => {
|
||||
const {container} = render(
|
||||
<Select
|
||||
label='Test label'
|
||||
value='1'
|
||||
choices={TEST_CHOICES}
|
||||
helpText='Help text'
|
||||
|
||||
onChange={onChangeHandler}
|
||||
/>
|
||||
);
|
||||
selectContainer = container;
|
||||
});
|
||||
|
||||
it('Test with snapshot.', () => {
|
||||
expect(selectContainer).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Test onChange handling.', () => {
|
||||
const select = getByDisplayValue(selectContainer, 'one');
|
||||
expect(select.value).toBe('1');
|
||||
fireEvent.change(select, {target: {value: '2'}});
|
||||
|
||||
const option = getByText(selectContainer, 'two');
|
||||
expect(onChangeHandler).toBeCalled();
|
||||
|
||||
expect(option.value).toBe('2');
|
||||
})
|
||||
});
|
27
src/bootstrap/__tests__/TextInput.test.js
Normal file
27
src/bootstrap/__tests__/TextInput.test.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
|
||||
import TextInput from '../components/TextInput';
|
||||
|
||||
describe('<TextInput/>', () => {
|
||||
it('Render text input', () => {
|
||||
const {container} = render(
|
||||
<TextInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
value="Some text"
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
37
src/bootstrap/__tests__/__snapshots__/Button.test.js.snap
Normal file
37
src/bootstrap/__tests__/__snapshots__/Button.test.js.snap
Normal file
@ -0,0 +1,37 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Button /> Render button correctly 1`] = `
|
||||
<button
|
||||
class="btn btn-primary "
|
||||
>
|
||||
|
||||
|
||||
Test Button
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`<Button /> Render button with custom classes 1`] = `
|
||||
<button
|
||||
class="btn one two three"
|
||||
>
|
||||
|
||||
|
||||
Test Button
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`<Button /> Render button with spinner 1`] = `
|
||||
<button
|
||||
class="btn btn-primary "
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
Test Button
|
||||
</button>
|
||||
`;
|
62
src/bootstrap/__tests__/__snapshots__/Checkbox.test.js.snap
Normal file
62
src/bootstrap/__tests__/__snapshots__/Checkbox.test.js.snap
Normal file
@ -0,0 +1,62 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Checkbox/> Render checkbox 1`] = `
|
||||
<div
|
||||
class="col-sm-12 offset-lg-1 col-lg-10"
|
||||
style="margin-bottom: 1rem;"
|
||||
>
|
||||
<div
|
||||
class="custom-control custom-checkbox"
|
||||
style="margin-bottom: 0px;"
|
||||
>
|
||||
<input
|
||||
checked=""
|
||||
class="custom-control-input"
|
||||
id="1"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="1"
|
||||
style="margin-bottom: 0px;"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`<Checkbox/> Render uncheked checkbox 1`] = `
|
||||
<div
|
||||
class="col-sm-12 offset-lg-1 col-lg-10"
|
||||
style="margin-bottom: 1rem;"
|
||||
>
|
||||
<div
|
||||
class="custom-control custom-checkbox"
|
||||
style="margin-bottom: 0px;"
|
||||
>
|
||||
<input
|
||||
class="custom-control-input"
|
||||
id="1"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="1"
|
||||
style="margin-bottom: 0px;"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
`;
|
@ -0,0 +1,32 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<NumberInput/> Render number input 1`] = `
|
||||
<div
|
||||
class="col-sm-12 offset-lg-1 col-lg-10"
|
||||
>
|
||||
<div
|
||||
class="form-group"
|
||||
>
|
||||
<label
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<div
|
||||
class="input-group"
|
||||
>
|
||||
<input
|
||||
class="form-control"
|
||||
id="1"
|
||||
type="number"
|
||||
value="1123"
|
||||
/>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -0,0 +1,33 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<PasswordInput/> Render password input 1`] = `
|
||||
<div
|
||||
class="col-sm-12 offset-lg-1 col-lg-10"
|
||||
>
|
||||
<div
|
||||
class="form-group"
|
||||
>
|
||||
<label
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<div
|
||||
class="input-group"
|
||||
>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="form-control"
|
||||
id="1"
|
||||
type="password"
|
||||
value="Some password"
|
||||
/>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
73
src/bootstrap/__tests__/__snapshots__/RadioSet.test.js.snap
Normal file
73
src/bootstrap/__tests__/__snapshots__/RadioSet.test.js.snap
Normal file
@ -0,0 +1,73 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<RadioSet/> Render radio set 1`] = `
|
||||
<div
|
||||
class="form-group col-sm-12 offset-lg-1 col-lg-10"
|
||||
style="margin-bottom: 1rem;"
|
||||
>
|
||||
<label
|
||||
class="col-12"
|
||||
for="1"
|
||||
style="padding-left: 0px;"
|
||||
>
|
||||
Radios set label
|
||||
</label>
|
||||
<div
|
||||
class="custom-control custom-radio custom-control-inline"
|
||||
>
|
||||
<input
|
||||
checked=""
|
||||
class="custom-control-input"
|
||||
id="test_name-0"
|
||||
name="test_name"
|
||||
type="radio"
|
||||
value="value"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="test_name-0"
|
||||
>
|
||||
label
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
class="custom-control custom-radio custom-control-inline"
|
||||
>
|
||||
<input
|
||||
class="custom-control-input"
|
||||
id="test_name-1"
|
||||
name="test_name"
|
||||
type="radio"
|
||||
value="another value"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="test_name-1"
|
||||
>
|
||||
another label
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
class="custom-control custom-radio custom-control-inline"
|
||||
>
|
||||
<input
|
||||
class="custom-control-input"
|
||||
id="test_name-2"
|
||||
name="test_name"
|
||||
type="radio"
|
||||
value="another on value"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="test_name-2"
|
||||
>
|
||||
another one label
|
||||
</label>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
`;
|
40
src/bootstrap/__tests__/__snapshots__/Select.test.js.snap
Normal file
40
src/bootstrap/__tests__/__snapshots__/Select.test.js.snap
Normal file
@ -0,0 +1,40 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Select/> Test with snapshot. 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="form-group col-sm-12 offset-lg-1 col-lg-10"
|
||||
>
|
||||
<label
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<select
|
||||
class="custom-select"
|
||||
id="1"
|
||||
>
|
||||
<option
|
||||
value="1"
|
||||
>
|
||||
one
|
||||
</option>
|
||||
<option
|
||||
value="2"
|
||||
>
|
||||
two
|
||||
</option>
|
||||
<option
|
||||
value="3"
|
||||
>
|
||||
three
|
||||
</option>
|
||||
</select>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
32
src/bootstrap/__tests__/__snapshots__/TextInput.test.js.snap
Normal file
32
src/bootstrap/__tests__/__snapshots__/TextInput.test.js.snap
Normal file
@ -0,0 +1,32 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<TextInput/> Render text input 1`] = `
|
||||
<div
|
||||
class="col-sm-12 offset-lg-1 col-lg-10"
|
||||
>
|
||||
<div
|
||||
class="form-group"
|
||||
>
|
||||
<label
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<div
|
||||
class="input-group"
|
||||
>
|
||||
<input
|
||||
class="form-control"
|
||||
id="1"
|
||||
type="text"
|
||||
value="Some text"
|
||||
/>
|
||||
</div>
|
||||
<small
|
||||
class="form-text text-muted"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
Reference in New Issue
Block a user