Revert "Refactor"

This reverts commit eaad2d56f0.
This commit is contained in:
Bastian Meissner 2021-07-16 11:00:15 +02:00
parent eaad2d56f0
commit fa28f68551
36 changed files with 962 additions and 368 deletions

View file

@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`app.tsx Tests app rendering with newTab=false 1`] = `[Function]`;
exports[`app.tsx Tests app rendering with newTab=true 1`] = `[Function]`;
exports[`app.tsx Tests app rendering without newTab 1`] = `[Function]`;

View file

@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`AppCategory snapshot test 1`] = `[Function]`;

View file

@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
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

@ -17,5 +17,3 @@ exports[`app.tsx Tests AppList rendering 2`] = `[Function]`;
exports[`app.tsx Tests AppList rendering 3`] = `[Function]`;
exports[`app.tsx Tests AppList rendering 4`] = `[Function]`;
exports[`app.tsx Tests AppList rendering without any props 1`] = `[Function]`;

View file

@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bookmarks.tsx Tests BookmarkGroup rendering 1`] = `[Function]`;
exports[`BookmarkGroup snapshot test 1`] = `[Function]`;
exports[`bookmarks.tsx Tests BookmarkList rendering with props 1`] = `[Function]`;
exports[`bookmarks.tsx Tests BookmarkList rendering without props 1`] = `[Function]`;
exports[`BookmarkList snapshot test 1`] = `[Function]`;

View file

@ -1,5 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`greeter.tsx tests greeter rendering with props 1`] = `[Function]`;
exports[`greeter.tsx tests greeter rendering without props 1`] = `[Function]`;
exports[`Greeter snapshot test 1`] = `[Function]`;

View file

@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`imprint.tsx Tests Imprint rendering with props 1`] = `[Function]`;
exports[`imprint.tsx Tests Imprint 1`] = `[Function]`;
exports[`imprint.tsx Tests ImprintField 1`] = `[Function]`;
exports[`imprint.tsx Tests imprint rendering without props 1`] = `[Function]`;

View file

@ -1,5 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`searchBar.tsx Tests SearchBar rendering with props 1`] = `[Function]`;
exports[`searchBar.tsx Tests SearchBar rendering without props 1`] = `[Function]`;
exports[`searchBar.tsx Tests SearchBar rendering 1`] = `[Function]`;

View file

@ -0,0 +1,52 @@
import { render } from "@testing-library/react";
import App, { IAppProps } from "../../components/app";
const props: IAppProps = {
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
};
describe("app.tsx", () => {
it("Tests app rendering with newTab=true", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
newTab={true}
/>,
);
expect(asFragment).toMatchSnapshot();
});
it("Tests app rendering with newTab=false", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
newTab={false}
/>,
);
expect(asFragment).toMatchSnapshot();
});
it("Tests app rendering without newTab", () => {
const { asFragment } = render(
<App
name={props.name}
icon={props.icon}
url={props.url}
displayURL={props.displayURL}
/>,
);
expect(asFragment).toMatchSnapshot();
});
});

View file

@ -0,0 +1,30 @@
import { render } from "@testing-library/react";
import AppCategory, { IAppCategoryProps } from "../../components/appCategory";
const props: IAppCategoryProps = {
name: "Category Test",
items: [
{
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
},
{
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
},
],
};
it("AppCategory snapshot test", () => {
const { asFragment } = render(
<AppCategory name={props.name} items={props.items} />,
);
expect(asFragment).toMatchSnapshot();
});

View file

@ -0,0 +1,60 @@
import { render } from "@testing-library/react";
import AppList, { IAppListProps } from "../../components/appList";
const props: IAppListProps = {
categories: [
{
name: "Category Test",
items: [
{
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
},
{
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
},
],
},
],
apps: [
{
name: "App Test",
icon: "bug_report",
url: "#",
displayURL: "test",
newTab: false,
},
],
};
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();
});
});

View file

@ -96,9 +96,4 @@ describe("app.tsx", () => {
expect(asFragment).toMatchSnapshot();
});
});
it("Tests AppList rendering without any props", () => {
const { asFragment } = render(<AppList />);
expect(asFragment).toMatchSnapshot();
});
});

View file

@ -19,28 +19,21 @@ const bookmarkListProps: IBookmarkListProps = {
groups: [bookmarkGroupProps, bookmarkGroupProps],
};
describe("bookmarks.tsx", () => {
it("Tests BookmarkGroup rendering", () => {
const { asFragment } = render(
<BookmarkGroup
name={bookmarkGroupProps.name}
items={bookmarkGroupProps.items}
/>,
);
it("BookmarkGroup snapshot test", () => {
const { asFragment } = render(
<BookmarkGroup
name={bookmarkGroupProps.name}
items={bookmarkGroupProps.items}
/>,
);
expect(asFragment).toMatchSnapshot();
});
it("Tests BookmarkList rendering with props", () => {
const { asFragment } = render(
<BookmarkList groups={bookmarkListProps.groups} />,
);
expect(asFragment).toMatchSnapshot();
});
it("Tests BookmarkList rendering without props", () => {
const { asFragment } = render(<BookmarkList />);
expect(asFragment).toMatchSnapshot();
});
expect(asFragment).toMatchSnapshot();
});
it("BookmarkList snapshot test", () => {
const { asFragment } = render(
<BookmarkList groups={bookmarkListProps.groups} />,
);
expect(asFragment).toMatchSnapshot();
});

View file

@ -54,31 +54,24 @@ const props: IGreeterProps = {
dateformat: "%wd, %m %d%e %y",
};
describe("greeter.tsx", () => {
it("tests isBetween", () => {
expect(isBetween(5, 1, 3)).toBeFalsy;
expect(isBetween(64, 1, 8)).toBeFalsy;
expect(isBetween(-1, -5, -3)).toBeFalsy;
expect(isBetween(4, 4, 4)).toBeTruthy;
expect(isBetween(3, 1, 8)).toBeTruthy;
expect(isBetween(-3, -5, -1)).toBeTruthy;
});
it("tests getExtension", () => {
expect(getExtension(0)).toEqual("th");
expect(getExtension(1)).toEqual("st");
expect(getExtension(2)).toEqual("nd");
expect(getExtension(3)).toEqual("rd");
expect(getExtension(15)).toEqual("th");
});
it("tests greeter rendering with props", () => {
const { asFragment } = render(<Greeter greeter={props} />);
expect(asFragment).toMatchSnapshot();
});
it("tests greeter rendering without props", () => {
const { asFragment } = render(<Greeter />);
expect(asFragment).toMatchSnapshot();
});
it("isBetween test", () => {
expect(isBetween(5, 1, 3)).toBeFalsy;
expect(isBetween(64, 1, 8)).toBeFalsy;
expect(isBetween(-1, -5, -3)).toBeFalsy;
expect(isBetween(4, 4, 4)).toBeTruthy;
expect(isBetween(3, 1, 8)).toBeTruthy;
expect(isBetween(-3, -5, -1)).toBeTruthy;
});
it("getExtension test", () => {
expect(getExtension(0)).toEqual("th");
expect(getExtension(1)).toEqual("st");
expect(getExtension(2)).toEqual("nd");
expect(getExtension(3)).toEqual("rd");
expect(getExtension(15)).toEqual("th");
});
it("Greeter snapshot test", () => {
const { asFragment } = render(<Greeter data={props} />);
expect(asFragment).toMatchSnapshot();
});

View file

@ -6,16 +6,26 @@ import Imprint, {
} from "../../components/imprint";
const props: IImprintProps = {
fields: [
{
text: "Test Field",
link: "#",
},
{
text: "Test Field",
link: "#",
},
],
name: {
text: "Test Name",
link: "#",
},
address: {
text: "Test Address",
link: "#",
},
phone: {
text: "Test Phone",
link: "#",
},
email: {
text: "Test Email",
link: "#",
},
url: {
text: "Test URL",
link: "#",
},
text: "This is a test!",
};
@ -32,16 +42,11 @@ describe("imprint.tsx", () => {
};
});
it("Tests Imprint rendering with props", () => {
it("Tests Imprint", () => {
const { asFragment } = render(<Imprint imprint={props} />);
expect(asFragment).toMatchSnapshot();
});
it("Tests imprint rendering without props", () => {
const { asFragment } = render(<Imprint />);
expect(asFragment).toMatchSnapshot();
});
it("Tests onClose with #imprint", () => {
const location = window.location.href;
window.location.href = location + "#imprint";
@ -56,7 +61,7 @@ describe("imprint.tsx", () => {
});
it("Tests ImprintField", () => {
const { asFragment } = render(<ImprintField field={props.fields[0]} />);
const { asFragment } = render(<ImprintField field={props.name} />);
expect(asFragment).toMatchSnapshot();
});
});

View file

@ -54,16 +54,11 @@ describe("searchBar.tsx", () => {
};
});
it("Tests SearchBar rendering with props", () => {
it("Tests SearchBar rendering", () => {
const { asFragment } = render(<SearchBar search={props} />);
expect(asFragment).toMatchSnapshot();
});
it("Tests SearchBar rendering without props", () => {
const { asFragment } = render(<SearchBar />);
expect(asFragment).toMatchSnapshot();
});
it("Tests handleQueryWithProvider", () => {
props.providers?.forEach((provider: ISearchProviderProps) => {
handleQueryWithProvider(props, provider.prefix + " test");

View file

@ -0,0 +1,46 @@
import { ok } from "assert";
import useFetcher, {
defaults,
handleResponse,
handleError,
fetchProduction,
fetchDevelopment,
} from "../../lib/fetcher";
describe("fetcher.tsx", () => {
it("Tests handleResponse", () => {});
it("Tests handleError", () => {
expect(handleError("apps", Error("Test!"))).toEqual({
...defaults.app,
error: "Test!",
});
expect(handleError("bookmark", Error("Test!"))).toEqual({
...defaults.bookmark,
error: "Test!",
});
expect(handleError("searchProvider", Error("Test!"))).toEqual({
...defaults.search,
error: "Test!",
});
expect(handleError("theme", Error("Test!"))).toEqual({
...defaults.theme,
error: "Test!",
});
expect(handleError("imprint", Error("Test!"))).toEqual({
...defaults.imprint,
error: "Test!",
});
expect(handleError("greeter", Error("Test!"))).toEqual({
...defaults.greeter,
error: "Test!",
});
expect(handleError("", Error("Test!"))).toEqual(undefined);
});
});

View file

@ -1,4 +1,4 @@
import { getTheme, IThemeProps, setTheme, setScheme } from "../../lib/useTheme";
import { getTheme, IThemeProps, setTheme } from "../../lib/useTheme";
const props: IThemeProps = {
label: "Classic",
@ -27,15 +27,7 @@ const setup = () => {
};
};
describe("useTheme.tsx", () => {
it("tests setScheme", () => {
setup();
setScheme("Test");
expect(window.localStorage.setItem).toHaveBeenCalledTimes(1);
expect(window.localStorage.setItem).toHaveBeenCalledWith("theme", "Test");
});
describe("theme.tsx", () => {
it("setTheme light test", () => {
setup();