Update existing tests
This commit is contained in:
parent
ee30f05e72
commit
9cdd8da178
6 changed files with 73 additions and 38 deletions
|
@ -4,8 +4,8 @@ import { IAppProps } from "./app";
|
|||
import { Headline, ListContainer } from "./elements";
|
||||
|
||||
export interface IAppListProps {
|
||||
categories: Array<IAppCategoryProps>;
|
||||
apps: Array<IAppProps>;
|
||||
categories?: Array<IAppCategoryProps>;
|
||||
apps?: Array<IAppProps>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,9 @@ export interface IAppListProps {
|
|||
* @param {IAppListProps} props props of the given list of apps
|
||||
* @returns {React.ReactNode} the app list component
|
||||
*/
|
||||
const AppList = ({ categories, apps }: IAppListProps) => (
|
||||
const AppList = ({ categories, apps }: IAppListProps) => {
|
||||
if (apps || categories) {
|
||||
return (
|
||||
<ListContainer>
|
||||
<Headline>Applications</Headline>
|
||||
{categories &&
|
||||
|
@ -21,9 +23,16 @@ const AppList = ({ categories, apps }: IAppListProps) => (
|
|||
<AppCategory key={[name, idx].join("")} name={name} items={items} />
|
||||
))}
|
||||
{apps && (
|
||||
<AppCategory name={categories ? "Uncategorized apps" : ""} items={apps} />
|
||||
<AppCategory
|
||||
name={categories ? "Uncategorized apps" : ""}
|
||||
items={apps}
|
||||
/>
|
||||
)}
|
||||
</ListContainer>
|
||||
);
|
||||
);
|
||||
} else {
|
||||
return <></>;
|
||||
}
|
||||
};
|
||||
|
||||
export default AppList;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import React from "react";
|
||||
import Modal from "./modal";
|
||||
import styled from "styled-components";
|
||||
import selectedTheme from "../lib/theme";
|
||||
|
@ -63,6 +62,12 @@ export const ImprintField = ({ field }: IImprintFieldComponentProps) => (
|
|||
<Link href={field.link}>{field.text}</Link>
|
||||
);
|
||||
|
||||
export const onClose = () => {
|
||||
if (window.location.href.endsWith("#imprint")) {
|
||||
window.location.href = window.location.href.replace("#imprint", "");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the imprint component
|
||||
* @param {IImprintProps} props contents of the imprint
|
||||
|
@ -80,14 +85,7 @@ const Imprint = ({ imprint }: IImprintComponentProps) => (
|
|||
text="View Imprint"
|
||||
title="Legal Disclosure"
|
||||
condition={!window.location.href.endsWith("#imprint")}
|
||||
onClose={() => {
|
||||
if (window.location.href.endsWith("#imprint")) {
|
||||
window.location.href = window.location.href.replace(
|
||||
"#imprint",
|
||||
"",
|
||||
);
|
||||
}
|
||||
}}
|
||||
onClose={onClose}
|
||||
>
|
||||
<div>
|
||||
<ModalSubHeadline>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`AppList snapshot test 1`] = `[Function]`;
|
||||
exports[`appList.tsx Tests AppList rendering with apps 1`] = `[Function]`;
|
||||
|
||||
exports[`appList.tsx Tests AppList rendering with categories 1`] = `[Function]`;
|
||||
|
||||
exports[`appList.tsx Tests AppList rendering with categories and apps 1`] = `[Function]`;
|
||||
|
||||
exports[`appList.tsx Tests AppList rendering with neither 1`] = `[Function]`;
|
||||
|
|
|
@ -34,10 +34,27 @@ const props: IAppListProps = {
|
|||
],
|
||||
};
|
||||
|
||||
it("AppList snapshot test", () => {
|
||||
describe("appList.tsx", () => {
|
||||
it("Tests AppList rendering with categories and apps", () => {
|
||||
const { asFragment } = render(
|
||||
<AppList categories={props.categories} apps={props.apps} />,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests AppList rendering with categories", () => {
|
||||
const { asFragment } = render(<AppList categories={props.categories} />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests AppList rendering with apps", () => {
|
||||
const { asFragment } = render(<AppList apps={props.apps} />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests AppList rendering with neither", () => {
|
||||
const { asFragment } = render(<AppList />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -64,11 +64,11 @@ it("isBetween test", () => {
|
|||
});
|
||||
|
||||
it("getExtension test", () => {
|
||||
expect(getExtension(0)).toEqual("");
|
||||
expect(getExtension(1)).toEqual("st");
|
||||
expect(getExtension(2)).toEqual("nd");
|
||||
expect(getExtension(3)).toEqual("rd");
|
||||
expect(getExtension(4)).toEqual("th");
|
||||
expect(getExtension(55)).toEqual("th");
|
||||
expect(getExtension(15)).toEqual("th");
|
||||
});
|
||||
|
||||
it("Greeter snapshot test", () => {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { fireEvent, render } from "@testing-library/react";
|
||||
import Imprint, { IImprintProps, ImprintField } from "../../components/imprint";
|
||||
import Imprint, {
|
||||
IImprintProps,
|
||||
ImprintField,
|
||||
onClose,
|
||||
} from "../../components/imprint";
|
||||
|
||||
const props: IImprintProps = {
|
||||
name: {
|
||||
|
@ -43,15 +47,16 @@ describe("imprint.tsx", () => {
|
|||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests #imprint", () => {
|
||||
it("Tests onClose with #imprint", () => {
|
||||
const location = window.location.href;
|
||||
window.location.href = location + "#imprint";
|
||||
onClose();
|
||||
expect(window.location.href).toEqual(location);
|
||||
});
|
||||
|
||||
const imprintModal = render(<Imprint imprint={props} />);
|
||||
|
||||
fireEvent.click(imprintModal.getByTestId("toggle-button"));
|
||||
//fireEvent.click(imprintModal.getByTestId("close-button"));
|
||||
|
||||
it("Tests onClose without #imprint", () => {
|
||||
const location = window.location.href;
|
||||
onClose();
|
||||
expect(window.location.href).toEqual(location);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue