Refactor
This commit is contained in:
parent
ca2f7a763d
commit
eaad2d56f0
36 changed files with 366 additions and 960 deletions
|
@ -1,7 +0,0 @@
|
|||
// 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]`;
|
|
@ -1,3 +0,0 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`AppCategory snapshot test 1`] = `[Function]`;
|
|
@ -1,9 +0,0 @@
|
|||
// 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]`;
|
|
@ -17,3 +17,5 @@ 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]`;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`BookmarkGroup snapshot test 1`] = `[Function]`;
|
||||
exports[`bookmarks.tsx Tests BookmarkGroup rendering 1`] = `[Function]`;
|
||||
|
||||
exports[`BookmarkList snapshot test 1`] = `[Function]`;
|
||||
exports[`bookmarks.tsx Tests BookmarkList rendering with props 1`] = `[Function]`;
|
||||
|
||||
exports[`bookmarks.tsx Tests BookmarkList rendering without props 1`] = `[Function]`;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Greeter snapshot test 1`] = `[Function]`;
|
||||
exports[`greeter.tsx tests greeter rendering with props 1`] = `[Function]`;
|
||||
|
||||
exports[`greeter.tsx tests greeter rendering without props 1`] = `[Function]`;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`imprint.tsx Tests Imprint 1`] = `[Function]`;
|
||||
exports[`imprint.tsx Tests Imprint rendering with props 1`] = `[Function]`;
|
||||
|
||||
exports[`imprint.tsx Tests ImprintField 1`] = `[Function]`;
|
||||
|
||||
exports[`imprint.tsx Tests imprint rendering without props 1`] = `[Function]`;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`searchBar.tsx Tests SearchBar rendering 1`] = `[Function]`;
|
||||
exports[`searchBar.tsx Tests SearchBar rendering with props 1`] = `[Function]`;
|
||||
|
||||
exports[`searchBar.tsx Tests SearchBar rendering without props 1`] = `[Function]`;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
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();
|
||||
});
|
||||
});
|
|
@ -1,30 +0,0 @@
|
|||
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();
|
||||
});
|
|
@ -1,60 +0,0 @@
|
|||
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();
|
||||
});
|
||||
});
|
|
@ -96,4 +96,9 @@ describe("app.tsx", () => {
|
|||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
it("Tests AppList rendering without any props", () => {
|
||||
const { asFragment } = render(<AppList />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,21 +19,28 @@ const bookmarkListProps: IBookmarkListProps = {
|
|||
groups: [bookmarkGroupProps, bookmarkGroupProps],
|
||||
};
|
||||
|
||||
it("BookmarkGroup snapshot test", () => {
|
||||
const { asFragment } = render(
|
||||
<BookmarkGroup
|
||||
name={bookmarkGroupProps.name}
|
||||
items={bookmarkGroupProps.items}
|
||||
/>,
|
||||
);
|
||||
describe("bookmarks.tsx", () => {
|
||||
it("Tests BookmarkGroup rendering", () => {
|
||||
const { asFragment } = render(
|
||||
<BookmarkGroup
|
||||
name={bookmarkGroupProps.name}
|
||||
items={bookmarkGroupProps.items}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("BookmarkList snapshot test", () => {
|
||||
const { asFragment } = render(
|
||||
<BookmarkList groups={bookmarkListProps.groups} />,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,24 +54,31 @@ const props: IGreeterProps = {
|
|||
dateformat: "%wd, %m %d%e %y",
|
||||
};
|
||||
|
||||
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;
|
||||
});
|
||||
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("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("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("Greeter snapshot test", () => {
|
||||
const { asFragment } = render(<Greeter data={props} />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,26 +6,16 @@ import Imprint, {
|
|||
} from "../../components/imprint";
|
||||
|
||||
const props: IImprintProps = {
|
||||
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: "#",
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
text: "Test Field",
|
||||
link: "#",
|
||||
},
|
||||
{
|
||||
text: "Test Field",
|
||||
link: "#",
|
||||
},
|
||||
],
|
||||
text: "This is a test!",
|
||||
};
|
||||
|
||||
|
@ -42,11 +32,16 @@ describe("imprint.tsx", () => {
|
|||
};
|
||||
});
|
||||
|
||||
it("Tests Imprint", () => {
|
||||
it("Tests Imprint rendering with props", () => {
|
||||
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";
|
||||
|
@ -61,7 +56,7 @@ describe("imprint.tsx", () => {
|
|||
});
|
||||
|
||||
it("Tests ImprintField", () => {
|
||||
const { asFragment } = render(<ImprintField field={props.name} />);
|
||||
const { asFragment } = render(<ImprintField field={props.fields[0]} />);
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,11 +54,16 @@ describe("searchBar.tsx", () => {
|
|||
};
|
||||
});
|
||||
|
||||
it("Tests SearchBar rendering", () => {
|
||||
it("Tests SearchBar rendering with props", () => {
|
||||
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");
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
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);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
import { getTheme, IThemeProps, setTheme } from "../../lib/useTheme";
|
||||
import { getTheme, IThemeProps, setTheme, setScheme } from "../../lib/useTheme";
|
||||
|
||||
const props: IThemeProps = {
|
||||
label: "Classic",
|
||||
|
@ -27,7 +27,15 @@ const setup = () => {
|
|||
};
|
||||
};
|
||||
|
||||
describe("theme.tsx", () => {
|
||||
describe("useTheme.tsx", () => {
|
||||
it("tests setScheme", () => {
|
||||
setup();
|
||||
|
||||
setScheme("Test");
|
||||
expect(window.localStorage.setItem).toHaveBeenCalledTimes(1);
|
||||
expect(window.localStorage.setItem).toHaveBeenCalledWith("theme", "Test");
|
||||
});
|
||||
|
||||
it("setTheme light test", () => {
|
||||
setup();
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue