mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-07-31 19:53:28 +02:00
Don't use default exports.
This commit is contained in:
@@ -22,7 +22,7 @@ Alert.propTypes = {
|
||||
onDismiss: PropTypes.func,
|
||||
};
|
||||
|
||||
export default function Alert({
|
||||
export function Alert({
|
||||
type, message, onDismiss, children,
|
||||
}) {
|
||||
return (
|
||||
|
@@ -29,7 +29,7 @@ Button.propTypes = {
|
||||
]).isRequired,
|
||||
};
|
||||
|
||||
export default function Button({
|
||||
export function Button({
|
||||
className, loading, forisFormSize, children, ...props
|
||||
}) {
|
||||
className = className ? `btn ${className}` : "btn btn-primary ";
|
||||
|
@@ -27,7 +27,7 @@ CheckBox.defaultProps = {
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
export default function CheckBox({
|
||||
export function CheckBox({
|
||||
label, helpText, useDefaultSize, disabled, ...props
|
||||
}) {
|
||||
const uid = useUID();
|
||||
|
@@ -10,7 +10,7 @@ import PropTypes from "prop-types";
|
||||
import Datetime from "react-datetime/DateTime";
|
||||
import moment from "moment/moment";
|
||||
|
||||
import Input from "./Input";
|
||||
import { Input } from "./Input";
|
||||
|
||||
DataTimeInput.propTypes = {
|
||||
/** Field label. */
|
||||
@@ -35,7 +35,7 @@ DataTimeInput.propTypes = {
|
||||
const DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
||||
const DEFAULT_TIME_FORMAT = "HH:mm:ss";
|
||||
|
||||
export default function DataTimeInput({
|
||||
export function DataTimeInput({
|
||||
value, onChange, isValidDate, dateFormat, timeFormat, children, ...props
|
||||
}) {
|
||||
function renderInput(datetimeProps) {
|
||||
|
@@ -8,9 +8,9 @@
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import Input from "./Input";
|
||||
import { Input } from "./Input";
|
||||
|
||||
const EmailInput = ({ ...props }) => <Input type="email" {...props} />;
|
||||
export const EmailInput = ({ ...props }) => <Input type="email" {...props} />;
|
||||
|
||||
|
||||
EmailInput.propTypes = {
|
||||
@@ -23,5 +23,3 @@ EmailInput.propTypes = {
|
||||
/** Email value. */
|
||||
value: PropTypes.string,
|
||||
};
|
||||
|
||||
export default EmailInput;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
import React from "react";
|
||||
import { useUID } from "react-uid/dist/es5/index";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { formFieldsSize } from "./constants";
|
||||
|
||||
Input.propTypes = {
|
||||
@@ -23,7 +24,7 @@ Input.propTypes = {
|
||||
};
|
||||
|
||||
/** Base bootstrap input component. */
|
||||
export default function Input({
|
||||
export function Input({
|
||||
type, label, helpText, error, className, children, ...props
|
||||
}) {
|
||||
const uid = useUID();
|
||||
|
@@ -7,7 +7,8 @@
|
||||
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import Portal from "utils/Portal";
|
||||
|
||||
import { Portal } from "utils/Portal";
|
||||
|
||||
Modal.propTypes = {
|
||||
/** Is modal shown value */
|
||||
|
@@ -8,9 +8,9 @@
|
||||
import React from "react";
|
||||
|
||||
import PropTypes from "prop-types";
|
||||
import Input from "./Input";
|
||||
import { Input } from "./Input";
|
||||
|
||||
const NumberInput = ({ ...props }) => <Input type="number" {...props} />;
|
||||
export const NumberInput = ({ ...props }) => <Input type="number" {...props} />;
|
||||
|
||||
NumberInput.propTypes = {
|
||||
/** Field label. */
|
||||
@@ -25,5 +25,3 @@ NumberInput.propTypes = {
|
||||
PropTypes.number,
|
||||
]),
|
||||
};
|
||||
|
||||
export default NumberInput;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
import React, { useState } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Input from "./Input";
|
||||
import { Input } from "./Input";
|
||||
|
||||
PasswordInput.propTypes = {
|
||||
/** Field label. */
|
||||
@@ -23,7 +23,7 @@ PasswordInput.propTypes = {
|
||||
withEye: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default function PasswordInput({ withEye, ...props }) {
|
||||
export function PasswordInput({ withEye, ...props }) {
|
||||
const [isHidden, setHidden] = useState(true);
|
||||
return (
|
||||
<Input
|
||||
|
@@ -30,7 +30,7 @@ RadioSet.propTypes = {
|
||||
helpText: PropTypes.string,
|
||||
};
|
||||
|
||||
export default function RadioSet({
|
||||
export function RadioSet({
|
||||
name, label, choices, value, helpText, ...props
|
||||
}) {
|
||||
const uid = useUID();
|
||||
|
@@ -24,7 +24,7 @@ Select.propTypes = {
|
||||
helpText: PropTypes.string,
|
||||
};
|
||||
|
||||
export default function Select({
|
||||
export function Select({
|
||||
label, choices, helpText, ...props
|
||||
}) {
|
||||
const uid = useUID();
|
||||
|
@@ -8,10 +8,10 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import Input from "./Input";
|
||||
import { Input } from "./Input";
|
||||
|
||||
|
||||
const TextInput = ({ ...props }) => <Input type="text" {...props} />;
|
||||
export const TextInput = ({ ...props }) => <Input type="text" {...props} />;
|
||||
|
||||
|
||||
TextInput.propTypes = {
|
||||
@@ -22,5 +22,3 @@ TextInput.propTypes = {
|
||||
/** Help text message. */
|
||||
helpText: PropTypes.string,
|
||||
};
|
||||
|
||||
export default TextInput;
|
||||
|
@@ -5,25 +5,28 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import Button from '../Button'
|
||||
import { Button } from "../Button";
|
||||
|
||||
describe('<Button />', () => {
|
||||
it('Render button correctly', () => {
|
||||
const {container} = render(<Button>Test Button</Button>);
|
||||
expect(container.firstChild).toMatchSnapshot()
|
||||
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 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()
|
||||
it("Render button with spinner", () => {
|
||||
const { container } = render(<Button loading={true}>Test Button</Button>);
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@@ -5,32 +5,35 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import CheckBox from '../Checkbox'
|
||||
import { CheckBox } from "../Checkbox";
|
||||
|
||||
describe('<Checkbox/>', () => {
|
||||
it('Render checkbox', () => {
|
||||
const {container} = render(
|
||||
describe("<Checkbox/>", () => {
|
||||
it("Render checkbox", () => {
|
||||
const { container } = render(
|
||||
<CheckBox
|
||||
label="Test label"
|
||||
checked
|
||||
helpText="Some help text"
|
||||
onChange={()=>{}}
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Render uncheked checkbox', () => {
|
||||
const {container} = render(
|
||||
it("Render uncheked checkbox", () => {
|
||||
const { container } = render(
|
||||
<CheckBox
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@@ -5,16 +5,16 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import NumberInput from '../NumberInput';
|
||||
import { NumberInput } from "../NumberInput";
|
||||
|
||||
|
||||
describe('<NumberInput/>', () => {
|
||||
it('Render number input', () => {
|
||||
const {container} = render(
|
||||
describe("<NumberInput/>", () => {
|
||||
it("Render number input", () => {
|
||||
const { container } = render(
|
||||
<NumberInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
@@ -23,6 +23,7 @@ describe('<NumberInput/>', () => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@@ -5,15 +5,15 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import PasswordInput from '../PasswordInput';
|
||||
import { PasswordInput } from "../PasswordInput";
|
||||
|
||||
describe('<PasswordInput/>', () => {
|
||||
it('Render password input', () => {
|
||||
const {container} = render(
|
||||
describe("<PasswordInput/>", () => {
|
||||
it("Render password input", () => {
|
||||
const { container } = render(
|
||||
<PasswordInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
@@ -22,6 +22,7 @@ describe('<PasswordInput/>', () => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@@ -5,31 +5,41 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import RadioSet from '../RadioSet';
|
||||
import { RadioSet } from "../RadioSet";
|
||||
|
||||
const TEST_CHOICES = [
|
||||
{label: 'label', value: 'value'},
|
||||
{label: 'another label', value: 'another value'},
|
||||
{label: 'another one label', value: 'another on value'}
|
||||
{
|
||||
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(
|
||||
describe("<RadioSet/>", () => {
|
||||
it("Render radio set", () => {
|
||||
const { container } = render(
|
||||
<RadioSet
|
||||
name={'test_name'}
|
||||
name={"test_name"}
|
||||
label='Radios set label'
|
||||
value='value'
|
||||
choices={TEST_CHOICES}
|
||||
helpText={'Some help text'}
|
||||
helpText={"Some help text"}
|
||||
onChange={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@@ -5,23 +5,23 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {fireEvent, getByDisplayValue, getByText, render} from 'customTestRender';
|
||||
import { fireEvent, getByDisplayValue, getByText, render } from "customTestRender";
|
||||
|
||||
import Select from '../Select';
|
||||
import { Select } from "../Select";
|
||||
|
||||
const TEST_CHOICES = {
|
||||
'1': 'one',
|
||||
'2': 'two',
|
||||
'3': 'three',
|
||||
"1": "one",
|
||||
"2": "two",
|
||||
"3": "three",
|
||||
};
|
||||
|
||||
describe('<Select/>', () => {
|
||||
describe("<Select/>", () => {
|
||||
var selectContainer;
|
||||
const onChangeHandler = jest.fn();
|
||||
beforeEach(() => {
|
||||
const {container} = render(
|
||||
const { container } = render(
|
||||
<Select
|
||||
label='Test label'
|
||||
value='1'
|
||||
@@ -34,18 +34,22 @@ describe('<Select/>', () => {
|
||||
selectContainer = container;
|
||||
});
|
||||
|
||||
it('Test with snapshot.', () => {
|
||||
expect(selectContainer).toMatchSnapshot();
|
||||
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'}});
|
||||
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();
|
||||
const option = getByText(selectContainer, "two");
|
||||
expect(onChangeHandler)
|
||||
.toBeCalled();
|
||||
|
||||
expect(option.value).toBe('2');
|
||||
})
|
||||
expect(option.value)
|
||||
.toBe("2");
|
||||
});
|
||||
});
|
||||
|
@@ -5,15 +5,15 @@
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
import {render} from 'customTestRender';
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import TextInput from '../TextInput';
|
||||
import { TextInput } from "../TextInput";
|
||||
|
||||
describe('<TextInput/>', () => {
|
||||
it('Render text input', () => {
|
||||
const {container} = render(
|
||||
describe("<TextInput/>", () => {
|
||||
it("Render text input", () => {
|
||||
const { container } = render(
|
||||
<TextInput
|
||||
label="Test label"
|
||||
helpText="Some help text"
|
||||
@@ -22,6 +22,7 @@ describe('<TextInput/>', () => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
expect(container.firstChild)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user