mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-16 13:46:16 +02:00
Format all files with Prettier
This commit is contained in:
@ -9,7 +9,12 @@ import React from "react";
|
||||
import { render } from "customTestRender";
|
||||
import { API_STATE } from "api/utils";
|
||||
import {
|
||||
withEither, withSpinner, withSending, withSpinnerOnSending, withError, withErrorMessage,
|
||||
withEither,
|
||||
withSpinner,
|
||||
withSending,
|
||||
withSpinnerOnSending,
|
||||
withError,
|
||||
withErrorMessage,
|
||||
} from "../conditionalHOCs";
|
||||
|
||||
describe("conditional HOCs", () => {
|
||||
@ -52,14 +57,18 @@ describe("conditional HOCs", () => {
|
||||
it("should render First component", () => {
|
||||
const withAlternative = withSending(Alternative);
|
||||
const FirstWithConditional = withAlternative(First);
|
||||
const { getByText } = render(<FirstWithConditional apiState={API_STATE.SUCCESS} />);
|
||||
const { getByText } = render(
|
||||
<FirstWithConditional apiState={API_STATE.SUCCESS} />
|
||||
);
|
||||
expect(getByText("First")).toBeDefined();
|
||||
});
|
||||
|
||||
it("should render Alternative component", () => {
|
||||
const withAlternative = withSending(Alternative);
|
||||
const FirstWithConditional = withAlternative(First);
|
||||
const { getByText } = render(<FirstWithConditional apiState={API_STATE.SENDING} />);
|
||||
const { getByText } = render(
|
||||
<FirstWithConditional apiState={API_STATE.SENDING} />
|
||||
);
|
||||
expect(getByText("Alternative")).toBeDefined();
|
||||
});
|
||||
});
|
||||
@ -67,13 +76,17 @@ describe("conditional HOCs", () => {
|
||||
describe("withSpinnerOnSending", () => {
|
||||
it("should render First component", () => {
|
||||
const FirstWithConditional = withSpinnerOnSending(First);
|
||||
const { getByText } = render(<FirstWithConditional apiState={API_STATE.SUCCESS} />);
|
||||
const { getByText } = render(
|
||||
<FirstWithConditional apiState={API_STATE.SUCCESS} />
|
||||
);
|
||||
expect(getByText("First")).toBeDefined();
|
||||
});
|
||||
|
||||
it("should render spinner", () => {
|
||||
const FirstWithConditional = withSpinnerOnSending(First);
|
||||
const { container } = render(<FirstWithConditional apiState={API_STATE.SENDING} />);
|
||||
const { container } = render(
|
||||
<FirstWithConditional apiState={API_STATE.SENDING} />
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@ -97,13 +110,17 @@ describe("conditional HOCs", () => {
|
||||
describe("withErrorMessage", () => {
|
||||
it("should render First component", () => {
|
||||
const FirstWithConditional = withErrorMessage(First);
|
||||
const { getByText } = render(<FirstWithConditional apiState={API_STATE.SUCCESS} />);
|
||||
const { getByText } = render(
|
||||
<FirstWithConditional apiState={API_STATE.SUCCESS} />
|
||||
);
|
||||
expect(getByText("First")).toBeDefined();
|
||||
});
|
||||
|
||||
it("should render error message", () => {
|
||||
const FirstWithConditional = withErrorMessage(First);
|
||||
const { container } = render(<FirstWithConditional apiState={API_STATE.ERROR} />);
|
||||
const { container } = render(
|
||||
<FirstWithConditional apiState={API_STATE.ERROR} />
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
@ -10,42 +10,40 @@ import { toLocaleDateString } from "../datetime";
|
||||
describe("toLocaleDateString", () => {
|
||||
it("should work with different locale", () => {
|
||||
global.ForisTranslations = { locale: "fr" };
|
||||
expect(
|
||||
toLocaleDateString("2020-02-20T12:51:36+00:00")
|
||||
).toBe("20 février 2020 12:51");
|
||||
expect(toLocaleDateString("2020-02-20T12:51:36+00:00")).toBe(
|
||||
"20 février 2020 12:51"
|
||||
);
|
||||
global.ForisTranslations = { locale: "en" };
|
||||
})
|
||||
});
|
||||
|
||||
it("should convert with default format", () => {
|
||||
expect(
|
||||
toLocaleDateString("2020-02-20T12:51:36+00:00")
|
||||
).toBe("February 20, 2020 12:51 PM");
|
||||
expect(toLocaleDateString("2020-02-20T12:51:36+00:00")).toBe(
|
||||
"February 20, 2020 12:51 PM"
|
||||
);
|
||||
});
|
||||
|
||||
it("should convert with custom input format", () => {
|
||||
expect(
|
||||
toLocaleDateString(
|
||||
"2020-02-20 12:51:36 +0000",
|
||||
{ inputFormat: "YYYY-MM-DD HH:mm:ss Z" },
|
||||
)
|
||||
toLocaleDateString("2020-02-20 12:51:36 +0000", {
|
||||
inputFormat: "YYYY-MM-DD HH:mm:ss Z",
|
||||
})
|
||||
).toBe("February 20, 2020 12:51 PM");
|
||||
});
|
||||
|
||||
it("should convert with custom output format", () => {
|
||||
expect(
|
||||
toLocaleDateString(
|
||||
"2020-02-20T12:51:36+00:00",
|
||||
{ outputFormat: "LL" },
|
||||
)
|
||||
toLocaleDateString("2020-02-20T12:51:36+00:00", {
|
||||
outputFormat: "LL",
|
||||
})
|
||||
).toBe("February 20, 2020");
|
||||
});
|
||||
|
||||
it("should convert with custom input and output format", () => {
|
||||
expect(
|
||||
toLocaleDateString(
|
||||
"2020-02-20 12:51:36 +0000",
|
||||
{ inputFormat: "YYYY-MM-DD HH:mm:ss Z", outputFormat: "LL" },
|
||||
)
|
||||
toLocaleDateString("2020-02-20 12:51:36 +0000", {
|
||||
inputFormat: "YYYY-MM-DD HH:mm:ss Z",
|
||||
outputFormat: "LL",
|
||||
})
|
||||
).toBe("February 20, 2020");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user