diff --git a/starsky/starsky/clientapp/package.json b/starsky/starsky/clientapp/package.json index 6baefc5924..ee953f90d1 100644 --- a/starsky/starsky/clientapp/package.json +++ b/starsky/starsky/clientapp/package.json @@ -13,6 +13,7 @@ "format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}'", "test": "jest --watch", "test:ci": "jest --ci --coverage --silent", + "test-ci": "npm run test:ci", "test:ci:debug": "jest --ci --coverage", "preview": "vite preview", "tsc": "tsc" diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-pagination/archive-pagination.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-pagination/archive-pagination.spec.tsx index 0542ccd046..85eb44defe 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-pagination/archive-pagination.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-pagination/archive-pagination.spec.tsx @@ -1,4 +1,5 @@ import { render } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; import { IRelativeObjects, newIRelativeObjects @@ -7,7 +8,11 @@ import ArchivePagination from "./archive-pagination"; describe("ArchivePagination", () => { it("renders new object", () => { - render(); + render( + + + + ); }); const relativeObjects = { @@ -17,7 +22,9 @@ describe("ArchivePagination", () => { it("next page exist", () => { const Component = render( - + + + ); const next = Component.queryByTestId( "archive-pagination-next" @@ -27,7 +34,9 @@ describe("ArchivePagination", () => { it("prev page exist", () => { const Component = render( - + + + ); const next = Component.queryByTestId( "archive-pagination-prev" diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-color-class.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-color-class.spec.tsx index a1efa0a975..ea187dd62c 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-color-class.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-color-class.spec.tsx @@ -53,11 +53,6 @@ describe("ArchiveSidebarColorClass", () => { dispatch } as AppContext.IArchiveContext; - jest.mock("@reach/router", () => ({ - navigate: jest.fn(), - globalHistory: jest.fn() - })); - // to use with: => import { act } from 'react-dom/test-utils'; Router.navigate("/?select=test.jpg"); diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-add-overwrite.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-add-overwrite.spec.tsx index 468470b514..52aeb23d5a 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-add-overwrite.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-add-overwrite.spec.tsx @@ -69,11 +69,6 @@ describe("ArchiveSidebarLabelEditAddOverwrite", () => { } } as AppContext.IArchiveContext; - jest.mock("@reach/router", () => ({ - navigate: jest.fn(), - globalHistory: jest.fn() - })); - act(() => { // to use with: => import { act } from 'react-dom/test-utils'; Router.navigate("/?select=test.jpg"); diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-search-replace.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-search-replace.spec.tsx index 24d0c2d7f1..8cc90859ce 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-search-replace.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-label-edit-search-replace.spec.tsx @@ -69,11 +69,6 @@ describe("ArchiveSidebarLabelEditAddOverwrite", () => { } } as AppContext.IArchiveContext; - jest.mock("@reach/router", () => ({ - navigate: jest.fn(), - globalHistory: jest.fn() - })); - act(() => { // to use with: => import { act } from 'react-dom/test-utils'; Router.navigate("/?select=test.jpg"); diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx index 4511b00e04..b6a1b2da7f 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.spec.tsx @@ -3,10 +3,9 @@ import { IFileIndexItem, newIFileIndexItemArray } from "../../../interfaces/IFileIndexItem"; +import { Router } from "../../../router-app/router-app"; import { URLPath } from "../../../shared/url-path"; import ArchiveSidebarSelectionList from "./archive-sidebar-selection-list"; -; - describe("archive-sidebar-selection-list", () => { it("renders", () => { render( @@ -16,14 +15,9 @@ describe("archive-sidebar-selection-list", () => { describe("with select state", () => { beforeEach(() => { - jest.mock("@reach/router", () => ({ - navigate: jest.fn(), - globalHistory: jest.fn() - })); - act(() => { // to use with: => import { act } from 'react-dom/test-utils'; - window.location.replace("/?select=test.jpg"); + Router.navigate("/?select=test.jpg"); }); }); diff --git a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.stories.tsx b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.stories.tsx index 878d571078..4a6be33f4e 100644 --- a/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.stories.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/archive-sidebar/archive-sidebar-selection-list.stories.tsx @@ -2,8 +2,6 @@ import { ArchiveContextProvider } from "../../../contexts/archive-context"; import { IArchiveProps } from "../../../interfaces/IArchiveProps"; import { newIFileIndexItemArray } from "../../../interfaces/IFileIndexItem"; import ArchiveSidebarSelectionList from "./archive-sidebar-selection-list"; -; - export default { title: "components/molecules/archive-sidebar/selection-list" }; diff --git a/starsky/starsky/clientapp/src/components/molecules/color-class-filter/color-class-filter.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/color-class-filter/color-class-filter.spec.tsx index a33e88427b..2ecfcc05fa 100644 --- a/starsky/starsky/clientapp/src/components/molecules/color-class-filter/color-class-filter.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/color-class-filter/color-class-filter.spec.tsx @@ -1,28 +1,32 @@ import { act, render, screen } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; +import { Router } from "../../../router-app/router-app"; import { URLPath } from "../../../shared/url-path"; import ColorClassFilter from "./color-class-filter"; -; - describe("ColorClassFilter", () => { it("renders", () => { render( - + + + ); }); it("onClick value", () => { const component = render( - + + + ); const colorClass = screen.queryByTestId( @@ -52,12 +56,14 @@ describe("ColorClassFilter", () => { it("outside current scope display reset", () => { const component = render( - + + + ); expect(screen.getByTestId("color-class-filter-reset")).toBeTruthy(); @@ -67,12 +73,14 @@ describe("ColorClassFilter", () => { it("onClick value and preloader exist", () => { const component = render( - + + + ); const colorClass = screen.queryByTestId( @@ -91,15 +99,17 @@ describe("ColorClassFilter", () => { }); it("undo selection when clicking on already selected colorclass", () => { - window.location.replace("/?colorclass=1"); + Router.navigate("/?colorclass=1"); const component = render( - + + + ); const colorClass = screen.queryByTestId( diff --git a/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.spec.tsx index ff2cd619ca..2bcd8aa23a 100644 --- a/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.spec.tsx @@ -1,5 +1,6 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { act } from "react-dom/test-utils"; +import { MemoryRouter } from "react-router-dom"; import { IFileIndexItem, newIFileIndexItemArray @@ -26,11 +27,13 @@ describe("ItemListView", () => { it("search with data-filepath in child element", () => { const component = render( - + + + ); const element = screen.queryAllByTestId( @@ -50,11 +53,13 @@ describe("ItemListView", () => { .spyOn(FlatListItem, "default") .mockImplementationOnce(() => <>); const component = render( - + + + ); expect(flatListItemSpy).toBeCalled(); component.unmount(); @@ -62,11 +67,13 @@ describe("ItemListView", () => { it("no content", () => { const component = render( - + + + ); expect(component.container.textContent).toBe("no content"); }); @@ -157,11 +164,13 @@ describe("ItemListView", () => { }); const component = render( - + + + ); const item = screen.queryByTestId( @@ -199,11 +208,13 @@ describe("ItemListView", () => { .spyOn(ListImageChildItem, "default") .mockImplementationOnce(() => <>t); const component = render( - + + + ); expect(listImageChildItemSpy).toBeCalled(); component.unmount(); diff --git a/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.stories.tsx b/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.stories.tsx index 68b31003db..8e96699fc1 100644 --- a/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.stories.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/item-list-view/item-list-view.stories.tsx @@ -3,8 +3,6 @@ import { newIFileIndexItemArray } from "../../../interfaces/IFileIndexItem"; import ItemListView from "./item-list-view"; -; - const exampleData8Selected = [ { fileName: "test.jpg", filePath: "/test.jpg", lastEdited: "1" }, { fileName: "test2.jpg", filePath: "/test2.jpg", lastEdited: "1" }, diff --git a/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.spec.tsx index 11c48b03c2..464413fbb5 100644 --- a/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.spec.tsx @@ -1,4 +1,5 @@ import { fireEvent, render, screen } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; import { IExifStatus } from "../../../interfaces/IExifStatus"; import { IFileIndexItem } from "../../../interfaces/IFileIndexItem"; import ListImageNormalSelectContainer from "./list-image-view-select-container"; @@ -8,7 +9,11 @@ describe("ListImageTest", () => { fileName: "test", status: IExifStatus.Ok } as IFileIndexItem; - render(); + render( + + + + ); }); describe("NonSelectMode", () => { @@ -22,9 +27,9 @@ describe("ListImageTest", () => { status: IExifStatus.Ok } as IFileIndexItem; const component = render( - - t - + + + ); const anchor = component.container.querySelector( @@ -50,7 +55,9 @@ describe("ListImageTest", () => { status: IExifStatus.Ok } as IFileIndexItem; const component = render( - + + + ); const anchor = component.container.querySelector( @@ -86,12 +93,12 @@ describe("ListImageTest", () => { const onSelectionCallback = jest.fn(); const component = render( - - t - + + + ); const button = component.container.querySelector( @@ -123,12 +130,12 @@ describe("ListImageTest", () => { const onSelectionCallback = jest.fn(); const component = render( - - t - + + + ); const button = component.container.querySelector( @@ -159,12 +166,12 @@ describe("ListImageTest", () => { } as IFileIndexItem; const component = render( - - t - + + + ); const button = component.container.querySelector( diff --git a/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.stories.tsx b/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.stories.tsx index 36917e7d1f..a519fd116b 100644 --- a/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.stories.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/list-image-view-select-container/list-image-view-select-container.stories.tsx @@ -1,8 +1,6 @@ import { IFileIndexItem } from "../../../interfaces/IFileIndexItem"; import ListImageChildItem from "../../atoms/list-image-child-item/list-image-child-item"; import ListImageBox from "./list-image-view-select-container"; -; - const fileIndexItem = { fileName: "test.jpg", colorClass: 1 diff --git a/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.spec.tsx b/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.spec.tsx index 5f5d1f7937..75cc76e7e2 100644 --- a/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.spec.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.spec.tsx @@ -1,8 +1,8 @@ import { render } from "@testing-library/react"; import { act } from "react-dom/test-utils"; +import { MemoryRouter } from "react-router-dom"; +import { Router } from "../../../router-app/router-app"; import SearchPagination from "./search-pagination"; -; - describe("SearchPagination", () => { it("renders", () => { render(); @@ -11,11 +11,13 @@ describe("SearchPagination", () => { it("next page exist", () => { act(() => { // to use with: => import { act } from 'react-dom/test-utils'; - window.location.replace("/?p=0"); + Router.navigate("/?p=0"); }); const component = render( - + + + ); const nextButton = component.queryByTestId( @@ -33,11 +35,13 @@ describe("SearchPagination", () => { it("prev page exist", () => { act(() => { // to use with: => import { act } from 'react-dom/test-utils'; - window.location.replace("/?p=1"); + Router.navigate("/?p=1"); }); const component = render( - + + + ); const prevButton = component.queryByTestId( @@ -53,11 +57,13 @@ describe("SearchPagination", () => { act(() => { // to use with: => import { act } from 'react-dom/test-utils'; - window.location.replace("/?p=1&select=test"); + Router.navigate("/?p=1&select=test"); }); const component = render( - + + + ); const prevButton = component.queryByTestId( @@ -72,11 +78,13 @@ describe("SearchPagination", () => { // due the fact that the selected item does not exist on that new page act(() => { // to use with: => import { act } from 'react-dom/test-utils'; - window.location.replace("/?p=0&select=test"); + Router.navigate("/?p=0&select=test"); }); const component = render( - + + + ); const nextButton = component.queryByTestId( diff --git a/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.spec.tsx index 8b614f3884..d5e3fab8a8 100644 --- a/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.spec.tsx @@ -2,9 +2,8 @@ import { act, render, screen } from "@testing-library/react"; import React, { useEffect } from "react"; import { PageType } from "../../../interfaces/IDetailView"; import { newIFileIndexItemArray } from "../../../interfaces/IFileIndexItem"; +import { Router } from "../../../router-app/router-app"; import ArchiveSidebar from "./archive-sidebar"; -; - describe("ArchiveSidebar", () => { it("renders", () => { jest.spyOn(window, "scrollTo").mockImplementationOnce(() => {}); @@ -25,7 +24,7 @@ describe("ArchiveSidebar", () => { jest.spyOn(window, "scrollTo").mockImplementationOnce(() => {}); jest.spyOn(React, "useLayoutEffect").mockImplementation(useEffect); - window.location.replace("/?sidebar=true"); + Router.navigate("/?sidebar=true"); }); it("restore scroll after unmount", () => { diff --git a/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.stories.tsx b/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.stories.tsx index 06b7035155..e4c0853cac 100644 --- a/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.stories.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/archive-sidebar/archive-sidebar.stories.tsx @@ -2,8 +2,6 @@ import { IArchiveProps } from "../../../interfaces/IArchiveProps"; import { PageType } from "../../../interfaces/IDetailView"; import { newIFileIndexItemArray } from "../../../interfaces/IFileIndexItem"; import ArchiveSidebar from "./archive-sidebar"; -; - export default { title: "components/organisms/archive-sidebar" }; diff --git a/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.stories.tsx b/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.stories.tsx index 5b22b1b094..2bfdf7d958 100644 --- a/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.stories.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.stories.tsx @@ -1,6 +1,4 @@ import MenuArchive from "./menu-archive"; -; - export default { title: "components/organisms/menu-archive" }; diff --git a/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.spec.tsx index d3c3448e4b..2d05aa3da7 100644 --- a/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.spec.tsx @@ -4,6 +4,7 @@ import { act } from "react-dom/test-utils"; import * as useHotKeys from "../../../hooks/use-keyboard/use-hotkeys"; import { IArchive } from "../../../interfaces/IArchive"; import { IExifStatus } from "../../../interfaces/IExifStatus"; +import { Router } from "../../../router-app/router-app"; import MenuSearch from "./menu-search"; describe("MenuSearch", () => { it("renders", () => { @@ -35,7 +36,7 @@ describe("MenuSearch", () => { }); it("un select items", () => { - window.location.replace("/?select=1"); + Router.navigate("/?select=1"); const component = render( { /> ); - expect(window.location.search).toBe("?select=1"); + expect(Router.state.location.search).toBe("?select=1"); const selected1 = screen.queryByTestId("selected-1") as HTMLDivElement; diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx index f4a1b3a4f1..b778956057 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx @@ -144,6 +144,7 @@ describe("ModalDisplayOptions", () => { }; jest .spyOn(useLocation, "default") + .mockReset() .mockImplementationOnce(() => spyObject) .mockImplementationOnce(() => spyObject); diff --git a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.spec.tsx index 6611c2585c..a9bd9c67e0 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.spec.tsx @@ -237,6 +237,7 @@ describe("PreferencesAppSettings", () => { // usage ==> import * as useFetch from '../../../hooks/use-fetch'; jest .spyOn(useFetch, "default") + .mockReset() .mockImplementationOnce(() => permissions) .mockImplementationOnce(() => appSettings) .mockImplementationOnce(() => permissions) diff --git a/starsky/starsky/clientapp/src/containers/detailview/detailview.spec.tsx b/starsky/starsky/clientapp/src/containers/detailview/detailview.spec.tsx index 14fadd966f..47c3cdd39b 100644 --- a/starsky/starsky/clientapp/src/containers/detailview/detailview.spec.tsx +++ b/starsky/starsky/clientapp/src/containers/detailview/detailview.spec.tsx @@ -227,6 +227,7 @@ describe("DetailView", () => { .spyOn(useFetch, "default") .mockReset() .mockImplementationOnce(() => newIConnectionDefault()) + .mockImplementationOnce(() => newIConnectionDefault()) .mockImplementationOnce(() => newIConnectionDefault()); // use as ==> import * as useLocation from '../hooks/use-location/use-location'; diff --git a/starsky/starsky/clientapp/src/containers/detailview/helpers/move-folder-up.spec.ts b/starsky/starsky/clientapp/src/containers/detailview/helpers/move-folder-up.spec.ts index 8dd9f10101..1b04f651ce 100644 --- a/starsky/starsky/clientapp/src/containers/detailview/helpers/move-folder-up.spec.ts +++ b/starsky/starsky/clientapp/src/containers/detailview/helpers/move-folder-up.spec.ts @@ -1,4 +1,3 @@ -import { HistoryLocation } from "@reach/router"; import { ModalOpenClassName } from "../../../components/atoms/modal/modal"; import { IUseLocation } from "../../../hooks/use-location/interfaces/IUseLocation"; import { IDetailView } from "../../../interfaces/IDetailView"; @@ -16,7 +15,7 @@ describe("statusRemoved", () => { }); it("should navigate [search query on]", () => { - const history = { location: {} as HistoryLocation } as IUseLocation; + const history = { location: {} } as IUseLocation; history.navigate = jest.fn(); moveFolderUp(new KeyboardEvent("delete"), history, true, { fileIndexItem: { @@ -28,7 +27,7 @@ describe("statusRemoved", () => { }); it("should navigate [search query off]", () => { - const history = { location: {} as HistoryLocation } as IUseLocation; + const history = { location: {} } as IUseLocation; history.navigate = jest.fn(); moveFolderUp(new KeyboardEvent("delete"), history, false, { fileIndexItem: { @@ -40,7 +39,7 @@ describe("statusRemoved", () => { }); it("should not navigate due isInForm", () => { - const history = { location: {} as HistoryLocation } as IUseLocation; + const history = { location: {} } as IUseLocation; history.navigate = jest.fn(); jest .spyOn(Keyboard.prototype, "isInForm") @@ -56,7 +55,7 @@ describe("statusRemoved", () => { }); it("should not navigate due portal", () => { - const history = { location: {} as HistoryLocation } as IUseLocation; + const history = { location: {} } as IUseLocation; history.navigate = jest.fn(); jest .spyOn(Keyboard.prototype, "isInForm") diff --git a/starsky/starsky/clientapp/src/containers/import/import.tsx b/starsky/starsky/clientapp/src/containers/import/import.tsx new file mode 100644 index 0000000000..e18c4d0626 --- /dev/null +++ b/starsky/starsky/clientapp/src/containers/import/import.tsx @@ -0,0 +1,53 @@ +import React, { FunctionComponent } from "react"; +import DropArea from "../../components/atoms/drop-area/drop-area"; +import ModalDropAreaFilesAdded from "../../components/molecules/modal-drop-area-files-added/modal-drop-area-files-added"; +import MenuDefault from "../../components/organisms/menu-default/menu-default"; +import useGlobalSettings from "../../hooks/use-global-settings"; +import { newIFileIndexItemArray } from "../../interfaces/IFileIndexItem"; +import DocumentTitle from "../../shared/document-title"; +import { Language } from "../../shared/language"; +import { UrlQuery } from "../../shared/url-query"; + +export const Import: FunctionComponent = () => { + document.title = new DocumentTitle().GetDocumentTitle("Import"); + + const [dropAreaUploadFilesList, setDropAreaUploadFilesList] = React.useState( + newIFileIndexItemArray() + ); + + // Content + const settings = useGlobalSettings(); + const language = new Language(settings.language); + const MessageImportName = language.text("Importeren", "Import"); + + return ( +
+ {/* DropArea output modal */} + {dropAreaUploadFilesList.length !== 0 ? ( + + setDropAreaUploadFilesList(newIFileIndexItemArray()) + } + uploadFilesList={dropAreaUploadFilesList} + isOpen={dropAreaUploadFilesList.length !== 0} + /> + ) : null} + + +
+
{MessageImportName}
+
+ { + setDropAreaUploadFilesList(add); + }} + endpoint={new UrlQuery().UrlImportApi()} + enableInputButton={true} + className="btn btn--default" + enableDragAndDrop={true} + > +
+
+
+ ); +}; diff --git a/starsky/starsky/clientapp/src/containers/login.spec.tsx b/starsky/starsky/clientapp/src/containers/login.spec.tsx index 10f9f79057..090765e1bc 100644 --- a/starsky/starsky/clientapp/src/containers/login.spec.tsx +++ b/starsky/starsky/clientapp/src/containers/login.spec.tsx @@ -4,7 +4,8 @@ import * as useFetch from "../hooks/use-fetch"; import { IConnectionDefault } from "../interfaces/IConnectionDefault"; import * as FetchPost from "../shared/fetch-post"; import { UrlQuery } from "../shared/url-query"; -import Login from "./login"; +import { Login } from "./login"; + describe("Login", () => { it("renders", () => { render(); diff --git a/starsky/starsky/clientapp/src/containers/login.tsx b/starsky/starsky/clientapp/src/containers/login.tsx index 94dfa1c133..7aad7fa950 100755 --- a/starsky/starsky/clientapp/src/containers/login.tsx +++ b/starsky/starsky/clientapp/src/containers/login.tsx @@ -15,7 +15,7 @@ export interface ILoginProps { defaultLoginStatus?: boolean; } -const Login: React.FC = () => { +export const Login: React.FC = () => { const history = useLocation(); const [userEmail, setUserEmail] = React.useState(""); const [userPassword, setUserPassword] = React.useState(""); @@ -266,5 +266,3 @@ const Login: React.FC = () => { ); }; - -export default Login; diff --git a/starsky/starsky/clientapp/src/containers/media-content.tsx b/starsky/starsky/clientapp/src/containers/media-content.tsx index 5471a71c68..ebb757db46 100644 --- a/starsky/starsky/clientapp/src/containers/media-content.tsx +++ b/starsky/starsky/clientapp/src/containers/media-content.tsx @@ -12,9 +12,9 @@ import useGlobalSettings from "../hooks/use-global-settings"; import useLocation from "../hooks/use-location/use-location"; import { IArchive } from "../interfaces/IArchive"; import { IDetailView, PageType } from "../interfaces/IDetailView"; -import NotFoundPage from "../pages/not-found-page"; +import { NotFoundPage } from "../pages/not-found-page"; import { Language } from "../shared/language"; -import Login from "./login"; +import { Login } from "./login"; const MediaContent: React.FC = () => { const history = useLocation(); diff --git a/starsky/starsky/clientapp/src/containers/menu-detailview-container/menu-detailview-container.spec.tsx b/starsky/starsky/clientapp/src/containers/menu-detailview-container/menu-detailview-container.spec.tsx index d47e16c77a..0e5ecc9b16 100644 --- a/starsky/starsky/clientapp/src/containers/menu-detailview-container/menu-detailview-container.spec.tsx +++ b/starsky/starsky/clientapp/src/containers/menu-detailview-container/menu-detailview-container.spec.tsx @@ -1,18 +1,27 @@ import { render } from "@testing-library/react"; import React from "react"; +import { MemoryRouter } from "react-router-dom"; import * as MenuDetailView from "../../components/organisms/menu-detail-view/menu-detail-view"; import MenuDetailViewContainer from "./menu-detailview-container"; describe("MenuDetailViewContainer", () => { it("renders", () => { - render(); + render( + + + + ); }); it("expect child object", () => { const menuDetailViewSpy = jest .spyOn(MenuDetailView, "default") .mockImplementationOnce(() => null); - const component = render(); + const component = render( + + + + ); expect(menuDetailViewSpy).toBeCalled(); component.unmount(); }); @@ -25,7 +34,11 @@ describe("MenuDetailViewContainer", () => { .spyOn(MenuDetailView, "default") .mockImplementationOnce(() => null); - const component = render(); + const component = render( + + + + ); expect(menuDetailViewSpy).toBeCalled(); component.unmount(); diff --git a/starsky/starsky/clientapp/src/containers/preferences/preferences.tsx b/starsky/starsky/clientapp/src/containers/preferences/preferences.tsx index dd47403e40..f7b0dde01e 100644 --- a/starsky/starsky/clientapp/src/containers/preferences/preferences.tsx +++ b/starsky/starsky/clientapp/src/containers/preferences/preferences.tsx @@ -5,7 +5,7 @@ import PreferencesUsername from "../../components/organisms/preferences-username import useGlobalSettings from "../../hooks/use-global-settings"; import { Language } from "../../shared/language"; -export const Preferences: React.FunctionComponent = () => { +export const Preferences: React.FunctionComponent = () => { const settings = useGlobalSettings(); const language = new Language(settings.language); const MessagePreferences = language.text("Voorkeuren", "Preferences"); @@ -21,5 +21,3 @@ export const Preferences: React.FunctionComponent = () => { ); }; - -export default Preferences; diff --git a/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.spec.tsx b/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.spec.tsx index 01d044faef..967ecaf727 100644 --- a/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.spec.tsx +++ b/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.spec.tsx @@ -79,7 +79,7 @@ describe("ArchiveContextWrapper", () => { fileIndexItems: [], pageType: PageType.Unauthorized } as IArchiveProps; - const login = jest.spyOn(Login, "default").mockImplementationOnce(() => { + const login = jest.spyOn(Login, "Login").mockImplementationOnce(() => { return <>; }); diff --git a/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.tsx b/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.tsx index 8d0d7e4dc0..5e939744c8 100644 --- a/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.tsx +++ b/starsky/starsky/clientapp/src/contexts-wrappers/archive-wrapper.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import Preloader from "../components/atoms/preloader/preloader"; import Archive from "../containers/archive"; -import Login from "../containers/login"; +import { Login } from "../containers/login"; import Search from "../containers/search"; import Trash from "../containers/trash"; import { diff --git a/starsky/starsky/clientapp/src/contexts-wrappers/detailview-wrapper.spec.tsx b/starsky/starsky/clientapp/src/contexts-wrappers/detailview-wrapper.spec.tsx index 33d3d2e1ea..bc2a66d534 100644 --- a/starsky/starsky/clientapp/src/contexts-wrappers/detailview-wrapper.spec.tsx +++ b/starsky/starsky/clientapp/src/contexts-wrappers/detailview-wrapper.spec.tsx @@ -1,4 +1,5 @@ import { render } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; import * as DetailView from "../containers/detailview/detailview"; import * as useDetailViewContext from "../contexts/detailview-context"; import { mountReactHook } from "../hooks/___tests___/test-hook"; @@ -11,7 +12,11 @@ import DetailViewWrapper, { describe("DetailViewWrapper", () => { it("renders", () => { - render(); + render( + + + + ); }); describe("with mount", () => { diff --git a/starsky/starsky/clientapp/src/pages/account-register-page.tsx b/starsky/starsky/clientapp/src/pages/account-register-page.tsx index 61317271b8..9d8326d9b2 100644 --- a/starsky/starsky/clientapp/src/pages/account-register-page.tsx +++ b/starsky/starsky/clientapp/src/pages/account-register-page.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; import AccountRegister from "../containers/account-register"; -const AccountRegisterPage: FunctionComponent = () => { +export const AccountRegisterPage: FunctionComponent = () => { return ; }; diff --git a/starsky/starsky/clientapp/src/pages/content-page.spec.tsx b/starsky/starsky/clientapp/src/pages/content-page.spec.tsx index c1405ca39f..471a69b163 100644 --- a/starsky/starsky/clientapp/src/pages/content-page.spec.tsx +++ b/starsky/starsky/clientapp/src/pages/content-page.spec.tsx @@ -1,6 +1,6 @@ import { render } from "@testing-library/react"; import * as MediaContent from "../containers/media-content"; -import ContentPage from "./content-page"; +import { ContentPage } from "./content-page"; describe("ContentPage", () => { it("default", () => { @@ -10,7 +10,7 @@ describe("ContentPage", () => { return <>; }); render(); - expect(mediaContentSpy).toBeCalledTimes(0); + expect(mediaContentSpy).toBeCalledTimes(1); }); it("with navigate and location", () => { diff --git a/starsky/starsky/clientapp/src/pages/content-page.tsx b/starsky/starsky/clientapp/src/pages/content-page.tsx index 58e9d33f5f..f167627c09 100644 --- a/starsky/starsky/clientapp/src/pages/content-page.tsx +++ b/starsky/starsky/clientapp/src/pages/content-page.tsx @@ -1,10 +1,6 @@ import { FunctionComponent } from "react"; import MediaContent from "../containers/media-content"; -interface IContentPageProps {} - -const ContentPage: FunctionComponent = () => { +export const ContentPage: FunctionComponent = () => { return ; }; - -export default ContentPage; diff --git a/starsky/starsky/clientapp/src/pages/import-page.tsx b/starsky/starsky/clientapp/src/pages/import-page.tsx index 6f6b23b946..b6b0a7f71e 100644 --- a/starsky/starsky/clientapp/src/pages/import-page.tsx +++ b/starsky/starsky/clientapp/src/pages/import-page.tsx @@ -1,55 +1,8 @@ -import React, { FunctionComponent } from "react"; -import DropArea from "../components/atoms/drop-area/drop-area"; -import ModalDropAreaFilesAdded from "../components/molecules/modal-drop-area-files-added/modal-drop-area-files-added"; -import MenuDefault from "../components/organisms/menu-default/menu-default"; -import useGlobalSettings from "../hooks/use-global-settings"; -import { newIFileIndexItemArray } from "../interfaces/IFileIndexItem"; -import DocumentTitle from "../shared/document-title"; -import { Language } from "../shared/language"; -import { UrlQuery } from "../shared/url-query"; +import { FunctionComponent } from "react"; +import { Import } from "../containers/import/import"; -const ImportPage: FunctionComponent = () => { - document.title = new DocumentTitle().GetDocumentTitle("Import"); - - const [dropAreaUploadFilesList, setDropAreaUploadFilesList] = React.useState( - newIFileIndexItemArray() - ); - - // Content - const settings = useGlobalSettings(); - const language = new Language(settings.language); - const MessageImportName = language.text("Importeren", "Import"); - - return ( -
- {/* DropArea output modal */} - {dropAreaUploadFilesList.length !== 0 ? ( - - setDropAreaUploadFilesList(newIFileIndexItemArray()) - } - uploadFilesList={dropAreaUploadFilesList} - isOpen={dropAreaUploadFilesList.length !== 0} - /> - ) : null} - - -
-
{MessageImportName}
-
- { - setDropAreaUploadFilesList(add); - }} - endpoint={new UrlQuery().UrlImportApi()} - enableInputButton={true} - className="btn btn--default" - enableDragAndDrop={true} - > -
-
-
- ); +export const ImportPage: FunctionComponent = () => { + return ; }; export default ImportPage; diff --git a/starsky/starsky/clientapp/src/pages/login-page.spec.tsx b/starsky/starsky/clientapp/src/pages/login-page.spec.tsx index f759338ca0..226a027bca 100644 --- a/starsky/starsky/clientapp/src/pages/login-page.spec.tsx +++ b/starsky/starsky/clientapp/src/pages/login-page.spec.tsx @@ -5,7 +5,7 @@ import LoginPage from "./login-page"; describe("LoginPage", () => { it("has Login child Component", () => { const spyLoginComponent = jest - .spyOn(Login, "default") + .spyOn(Login, "Login") .mockImplementationOnce(() => { return <>; }); diff --git a/starsky/starsky/clientapp/src/pages/login-page.tsx b/starsky/starsky/clientapp/src/pages/login-page.tsx index ec4eba0ef7..55a0413834 100644 --- a/starsky/starsky/clientapp/src/pages/login-page.tsx +++ b/starsky/starsky/clientapp/src/pages/login-page.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; -import Login from "../containers/login"; +import { Login } from "../containers/login"; -const LoginPage: FunctionComponent = () => { +export const LoginPage: FunctionComponent = () => { return ; }; diff --git a/starsky/starsky/clientapp/src/pages/not-found-page.spec.tsx b/starsky/starsky/clientapp/src/pages/not-found-page.spec.tsx index ea35d4440f..20867e73d6 100644 --- a/starsky/starsky/clientapp/src/pages/not-found-page.spec.tsx +++ b/starsky/starsky/clientapp/src/pages/not-found-page.spec.tsx @@ -1,9 +1,16 @@ import { render } from "@testing-library/react"; -import NotFoundPage from "./not-found-page"; +import { MemoryRouter } from "react-router-dom"; +import { NotFoundPage } from "./not-found-page"; describe("NotFoundPage", () => { it("has MenuDefault child Component", () => { - const notFoundComponent = render(); + jest.spyOn(console, "error").mockImplementationOnce(() => {}); + + const notFoundComponent = render( + + + + ); const headerText = ( notFoundComponent.container.querySelector( ".content--header" diff --git a/starsky/starsky/clientapp/src/pages/not-found-page.tsx b/starsky/starsky/clientapp/src/pages/not-found-page.tsx index 9aec27dc66..61e44a85a2 100644 --- a/starsky/starsky/clientapp/src/pages/not-found-page.tsx +++ b/starsky/starsky/clientapp/src/pages/not-found-page.tsx @@ -5,7 +5,7 @@ import useGlobalSettings from "../hooks/use-global-settings"; import { Language } from "../shared/language"; import { UrlQuery } from "../shared/url-query"; -const NotFoundPage: FunctionComponent = () => { +export const NotFoundPage: FunctionComponent = () => { // content const settings = useGlobalSettings(); const language = new Language(settings.language); @@ -19,7 +19,7 @@ const NotFoundPage: FunctionComponent = () => { return (
-
+
{MessageNotFound}
@@ -32,5 +32,3 @@ const NotFoundPage: FunctionComponent = () => {
); }; - -export default NotFoundPage; diff --git a/starsky/starsky/clientapp/src/pages/preferences-page.tsx b/starsky/starsky/clientapp/src/pages/preferences-page.tsx index 0997dccffc..27bd60c3f8 100644 --- a/starsky/starsky/clientapp/src/pages/preferences-page.tsx +++ b/starsky/starsky/clientapp/src/pages/preferences-page.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; -import Preferences from "../containers/preferences/preferences"; +import { Preferences } from "../containers/preferences/preferences"; -const PreferencesPage: FunctionComponent = () => { +export const PreferencesPage: FunctionComponent = () => { return ; }; diff --git a/starsky/starsky/clientapp/src/pages/search-page.tsx b/starsky/starsky/clientapp/src/pages/search-page.tsx index 53e6965470..20732d6cb9 100644 --- a/starsky/starsky/clientapp/src/pages/search-page.tsx +++ b/starsky/starsky/clientapp/src/pages/search-page.tsx @@ -7,7 +7,7 @@ import useSearchList from "../hooks/use-searchlist"; import { PageType } from "../interfaces/IDetailView"; import { URLPath } from "../shared/url-path"; -const SearchPage: FunctionComponent = () => { +export const SearchPage: FunctionComponent = () => { const history = useLocation(); const urlObject = new URLPath().StringToIUrl(history.location.search); diff --git a/starsky/starsky/clientapp/src/pages/trash-page.tsx b/starsky/starsky/clientapp/src/pages/trash-page.tsx index c29c6d5726..1d1de61665 100644 --- a/starsky/starsky/clientapp/src/pages/trash-page.tsx +++ b/starsky/starsky/clientapp/src/pages/trash-page.tsx @@ -7,7 +7,7 @@ import useSearchList from "../hooks/use-searchlist"; import { PageType } from "../interfaces/IDetailView"; import { URLPath } from "../shared/url-path"; -const TrashPage: FunctionComponent = () => { +export const TrashPage: FunctionComponent = () => { const history = useLocation(); const urlObject = new URLPath().StringToIUrl(history.location.search); diff --git a/starsky/starsky/clientapp/src/router-app/router-app.spec.tsx b/starsky/starsky/clientapp/src/router-app/router-app.spec.tsx index bfa0aa7527..0e2ecf70a1 100644 --- a/starsky/starsky/clientapp/src/router-app/router-app.spec.tsx +++ b/starsky/starsky/clientapp/src/router-app/router-app.spec.tsx @@ -1,83 +1,131 @@ import { render } from "@testing-library/react"; -import { RouterProvider, createMemoryRouter } from "react-router-dom"; -import * as ContentPage from "../pages/content-page"; -import * as ImportPage from "../pages/import-page"; -import * as LoginPage from "../pages/login-page"; +import * as Import from "../containers/import/import"; +import * as Login from "../containers/login"; +import * as MediaContent from "../containers/media-content"; +import * as Preferences from "../containers/preferences/preferences"; +import * as useSearchList from "../hooks/use-searchlist"; +import { ISearchList } from "../hooks/use-searchlist"; import * as NotFoundPage from "../pages/not-found-page"; import * as SearchPage from "../pages/search-page"; import * as TrashPage from "../pages/trash-page"; -import RouterApp, { RoutesConfig } from "./router-app"; +import RouterApp, { Router, RoutesConfig } from "./router-app"; + describe("Router", () => { it("default", () => { - const contentPageSpy = jest - .spyOn(ContentPage, "default") - .mockImplementationOnce(() => { - return <>; - }); + const searchPagePageSpy = jest + .spyOn(MediaContent, "default") + .mockImplementationOnce(() => <>); - const memoryRouter = createMemoryRouter(RoutesConfig, { - initialEntries: ["/"] - }); + const component = render(); - const component = render(); + expect( + RoutesConfig.find((x) => x.path === "/")?.element + ).not.toBeUndefined(); - console.log(component.container.innerHTML); + expect(searchPagePageSpy).toBeCalled(); - expect(contentPageSpy).toBeCalled(); + component.unmount(); }); - xit("search", () => { - const searchPagePageSpy = jest - .spyOn(SearchPage, "default") + it("search", () => { + jest.spyOn(SearchPage, "SearchPage").mockImplementationOnce(() => <>); + + const searchListMock = jest + .spyOn(useSearchList, "default") .mockImplementationOnce(() => { - return <>; + return [{} as ISearchList, () => {}] as any; }); - window.location.replace("/search?q=t"); - render(); - expect(searchPagePageSpy).toBeCalled(); + + Router.navigate("search?q=t"); + + const component = render(); + + expect(searchListMock).toBeCalled(); + expect(searchListMock).toBeCalledWith(undefined, undefined, true); + + component.unmount(); }); - xit("TrashPage", () => { - const trashPagePageSpy = jest - .spyOn(TrashPage, "default") + it("TrashPage", () => { + const searchListMock = jest + .spyOn(useSearchList, "default") + .mockReset() .mockImplementationOnce(() => { - return <>; + return [{} as ISearchList, () => {}] as any; }); - window.location.replace("/trash?q=t"); - render(); - expect(trashPagePageSpy).toBeCalled(); + + jest.spyOn(TrashPage, "TrashPage").mockImplementationOnce(() => { + return <>; + }); + + Router.navigate("/trash?q=t"); + + const component = render(); + + expect(searchListMock).toBeCalled(); + expect(searchListMock).toBeCalledWith("!delete!", undefined, true); + + component.unmount(); }); - xit("ImportPage", () => { + it("ImportPage", () => { const importPagePageSpy = jest - .spyOn(ImportPage, "default") + .spyOn(Import, "Import") .mockImplementationOnce(() => { return <>; }); - window.location.replace("/import?q=t"); - render(); + + Router.navigate("/import"); + + const component = render(); + expect(importPagePageSpy).toBeCalled(); + + component.unmount(); }); - xit("LoginPage", () => { + it("LoginPage", () => { const loginPagePageSpy = jest - .spyOn(LoginPage, "default") - .mockImplementationOnce(() => { - return <>; - }); - window.location.replace("/account/login"); - render(); + .spyOn(Login, "Login") + .mockImplementationOnce(() => <>); + + Router.navigate("/account/login"); + + const component = render(); + + console.log(component.container.innerHTML); + expect(loginPagePageSpy).toBeCalled(); + + component.unmount(); }); - xit("NotFoundPage", () => { - const notFoundPageSpy = jest - .spyOn(NotFoundPage, "default") + it("PreferencesPage", () => { + const preferencesPagePageSpy = jest + .spyOn(Preferences, "Preferences") .mockImplementationOnce(() => { return <>; }); - window.location.replace("/not-found"); - render(); - expect(notFoundPageSpy).toBeCalled(); + + Router.navigate("/preferences"); + + const component = render(); + + expect(preferencesPagePageSpy).toBeCalled(); + + component.unmount(); + }); + + it("NotFoundPage", () => { + jest + .spyOn(NotFoundPage, "NotFoundPage") + .mockImplementationOnce(() => <>); + + Router.navigate("/not-found"); + const component = render(); + + expect(component.queryByTestId("not-found-page")).not.toBeNull(); + + component.unmount(); }); }); diff --git a/starsky/starsky/clientapp/src/router-app/router-app.tsx b/starsky/starsky/clientapp/src/router-app/router-app.tsx index 087f25f06f..840c9724e2 100644 --- a/starsky/starsky/clientapp/src/router-app/router-app.tsx +++ b/starsky/starsky/clientapp/src/router-app/router-app.tsx @@ -1,13 +1,18 @@ -import { RouterProvider, createBrowserRouter } from "react-router-dom"; -import AccountRegisterPage from "../pages/account-register-page"; -import ContentPage from "../pages/content-page"; -import LoginPage from "../pages/login-page"; -import NotFoundPage from "../pages/not-found-page"; -import PreferencesPage from "../pages/preferences-page"; -import SearchPage from "../pages/search-page"; -import TrashPage from "../pages/trash-page"; +import { + RouteObject, + RouterProvider, + createBrowserRouter +} from "react-router-dom"; +import { AccountRegisterPage } from "../pages/account-register-page"; +import { ContentPage } from "../pages/content-page"; +import ImportPage from "../pages/import-page"; +import { LoginPage } from "../pages/login-page"; +import { NotFoundPage } from "../pages/not-found-page"; +import { PreferencesPage } from "../pages/preferences-page"; +import { SearchPage } from "../pages/search-page"; +import { TrashPage } from "../pages/trash-page"; -export const RoutesConfig = [ +export const RoutesConfig: RouteObject[] = [ { path: "/", element: , @@ -18,15 +23,18 @@ export const RoutesConfig = [ { path: "starsky/search", element: }, { path: "trash", element: }, { path: "starsky/trash", element: }, + { path: "import", element: }, + { path: "starsky/import", element: }, { path: "login", element: }, { path: "starsky/login", element: }, + { path: "account/login", element: }, + { path: "starsky/account/login", element: }, { path: "account/register", element: }, { path: "starsky/account/register", element: }, { path: "preferences", element: }, { path: "starsky/preferences", element: }, { path: "*", element: } ]; - export const Router = createBrowserRouter(RoutesConfig); const RouterApp = () => ; diff --git a/starsky/starsky/clientapp/src/shared/select.spec.ts b/starsky/starsky/clientapp/src/shared/select.spec.ts index 1a5ab6957f..52f692e90c 100644 --- a/starsky/starsky/clientapp/src/shared/select.spec.ts +++ b/starsky/starsky/clientapp/src/shared/select.spec.ts @@ -33,7 +33,7 @@ describe("select", () => { }); select.removeSidebarSelection(); - expect(Router.state.location.search).toBe(""); + expect(Router.state.location.search).toBe("?select="); expect(setSelectSpy).toBeCalled(); expect(setSelectSpy).toBeCalledWith(["1", "2"]); }); diff --git a/starsky/starsky/clientapp/src/shared/sidebar.spec.ts b/starsky/starsky/clientapp/src/shared/sidebar.spec.ts index aa0841b218..76a82c1971 100644 --- a/starsky/starsky/clientapp/src/shared/sidebar.spec.ts +++ b/starsky/starsky/clientapp/src/shared/sidebar.spec.ts @@ -30,7 +30,7 @@ describe("sidebar", () => { href: "", ...Router.state.location }, - navigate: Router.navigate + navigate: navigateSpy }); sidebar.toggleSidebar();