Update existing tests

This commit is contained in:
phntxx 2021-06-24 12:25:25 +02:00
parent ee30f05e72
commit 9cdd8da178
6 changed files with 73 additions and 38 deletions

View file

@ -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]`;

View file

@ -34,10 +34,27 @@ const props: IAppListProps = {
],
};
it("AppList snapshot test", () => {
const { asFragment } = render(
<AppList categories={props.categories} apps={props.apps} />,
);
describe("appList.tsx", () => {
it("Tests AppList rendering with categories and apps", () => {
const { asFragment } = render(
<AppList categories={props.categories} apps={props.apps} />,
);
expect(asFragment).toMatchSnapshot();
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();
});
});

View file

@ -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", () => {

View file

@ -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);
});