Skip to content

Commit

Permalink
#1866 eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Dec 16, 2024
1 parent ddb6744 commit 81805c1
Show file tree
Hide file tree
Showing 25 changed files with 152 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("ColorClassSelectKeyboard", () => {
.spyOn(ColorClassUpdateSingle, "ColorClassUpdateSingle")
.mockImplementationOnce((_p1, _p2, _p3, _p4, setIsError) => {
setIsError("true");
return { Update: jest.fn() } as any;
return { Update: jest.fn() } as unknown as ColorClassUpdateSingle.ColorClassUpdateSingle;
});

const component = render(
Expand Down Expand Up @@ -152,7 +152,7 @@ describe("ColorClassSelectKeyboard", () => {
.spyOn(ColorClassUpdateSingle, "ColorClassUpdateSingle")
.mockImplementationOnce((_p1, _p2, _p3, _p4, _p5, _p6, setCurrentColorClass) => {
setCurrentColorClass(1);
return { Update: jest.fn() } as any;
return { Update: jest.fn() } as unknown as ColorClassUpdateSingle.ColorClassUpdateSingle;
});

const component = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("ColorClassSelect", () => {
.spyOn(ColorClassUpdateSingle, "ColorClassUpdateSingle")
.mockImplementationOnce((_p1, _p2, _p3, _p4, setIsError) => {
setIsError("true");
return { Update: jest.fn() } as any;
return { Update: jest.fn() } as unknown as ColorClassUpdateSingle.ColorClassUpdateSingle;
});

const component = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe("HealthCheckForUpdates", () => {

it("There a no links in the Notification when using electron", () => {
// This is the difference
(window as any).isElectron = true;
(window as unknown as { isElectron: boolean }).isElectron = true;

const mockGetIConnectionDefault = {
statusCode: 202,
Expand All @@ -173,7 +173,7 @@ describe("HealthCheckForUpdates", () => {
expect(useFetchSpy).toHaveBeenCalled();

component.unmount();
(window as any).isElectron = null;
(window as unknown as { isElectron: null }).isElectron = null;
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
};

export const Default = () => {
(window as any).isElectron = undefined;
(window as unknown as { isElectron: unknown }).isElectron = undefined;
return (
<>
<button
Expand All @@ -25,7 +25,7 @@ export const Default = () => {
Default.storyName = "default";

export const Electron = () => {
(window as any).isElectron = true;
(window as unknown as { isElectron: boolean }).isElectron = true;
return (
<>
<b>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { render, screen } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import { IUseLocation } from "../../../hooks/use-location/interfaces/IUseLocation";
import { IDetailView } from "../../../interfaces/IDetailView";
import * as Link from "../../atoms/link/link";
import IsSearchQueryMenuSearchItem from "./is-search-query-menu-search-item";

Expand All @@ -11,14 +13,14 @@ describe("IsSearchQueryMenuSearchItem", () => {
search: "test"
},
navigate: jest.fn()
} as any;
} as unknown as IUseLocation;
render(
<BrowserRouter>
<IsSearchQueryMenuSearchItem
history={history}
setIsLoading={jest.fn()}
isSearchQuery={true}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
</BrowserRouter>
);
Expand All @@ -33,13 +35,13 @@ describe("IsSearchQueryMenuSearchItem", () => {
location: {
search: "test"
}
} as any;
} as unknown as IUseLocation;
render(
<IsSearchQueryMenuSearchItem
history={history}
setIsLoading={jest.fn()}
isSearchQuery={true}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
);

Expand All @@ -53,7 +55,7 @@ describe("IsSearchQueryMenuSearchItem", () => {
basename: "/",
search: "test"
}
} as any;
} as unknown as IUseLocation;

const loadingSpy = jest.fn();
render(
Expand All @@ -62,7 +64,7 @@ describe("IsSearchQueryMenuSearchItem", () => {
history={history}
setIsLoading={loadingSpy}
isSearchQuery={true}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
</BrowserRouter>
);
Expand All @@ -80,15 +82,15 @@ describe("IsSearchQueryMenuSearchItem", () => {
location: {
search: "test"
}
} as any;
} as unknown as IUseLocation;
const loadingSpy = jest.fn();
render(
<BrowserRouter>
<IsSearchQueryMenuSearchItem
history={history}
setIsLoading={loadingSpy}
isSearchQuery={true}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
</BrowserRouter>
);
Expand All @@ -106,14 +108,14 @@ describe("IsSearchQueryMenuSearchItem", () => {
location: {
search: "?t=!delete!"
}
} as any;
} as unknown as IUseLocation;
render(
<BrowserRouter>
<IsSearchQueryMenuSearchItem
history={history}
setIsLoading={jest.fn()}
isSearchQuery={true}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
</BrowserRouter>
);
Expand All @@ -129,13 +131,13 @@ describe("IsSearchQueryMenuSearchItem", () => {
location: {
search: "test"
}
} as any;
} as unknown as IUseLocation;
render(
<IsSearchQueryMenuSearchItem
history={history}
setIsLoading={jest.fn()}
isSearchQuery={false}
state={{ fileIndexItem: {} } as any}
state={{ fileIndexItem: {} } as IDetailView}
/>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { newIFileIndexItem, newIFileIndexItemArray } from "../../../../interfaces/IFileIndexItem";
import {
IFileIndexItem,
newIFileIndexItem,
newIFileIndexItemArray
} from "../../../../interfaces/IFileIndexItem";
import { ShiftSelectionHelper } from "./shift-selection-helper";
describe("ShiftSelectionHelper", () => {
it("items undefined", () => {
Expand All @@ -9,7 +13,7 @@ describe("ShiftSelectionHelper", () => {
},
[],
"test",
undefined as any
undefined as unknown as IFileIndexItem[]
);
expect(result).toBeFalsy();
});
Expand All @@ -20,7 +24,7 @@ describe("ShiftSelectionHelper", () => {
navigate: jest.fn(),
location: window.location
},
undefined as any,
undefined as unknown as string[],
"test",
newIFileIndexItemArray()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ describe("ItemListView", () => {
it("no content", () => {
const component = render(
<MemoryRouter>
<ItemListView iconList={true} fileIndexItems={undefined as any} colorClassUsage={[]} />
<ItemListView
iconList={true}
fileIndexItems={undefined as unknown as IFileIndexItem[]}
colorClassUsage={[]}
/>
</MemoryRouter>
);
expect(component.container.textContent).toBe("no content");
Expand Down Expand Up @@ -99,7 +103,7 @@ describe("ItemListView", () => {

// https://stackoverflow.com/questions/43694975/jest-enzyme-using-mount-document-getelementbyid-returns-null-on-componen
const div = document.createElement("div");
(window as any).domNode = div;
(window as unknown as { domNode: HTMLElement }).domNode = div;
document.body.appendChild(div);

const useLocationMock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ describe("ItemTextListView", () => {
});

it("renders undefined", () => {
render(<ItemTextListView fileIndexItems={undefined as any} callback={() => {}} />);
render(
<ItemTextListView
fileIndexItems={undefined as unknown as IFileIndexItem[]}
callback={() => {}}
/>
);

expect(screen.getByTestId("list-text-view-no-photos-in-folder")).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe("ListImageTest", () => {
<MemoryRouter>
<ListImageNormalSelectContainer
item={fileIndexItem}
onSelectionCallback={undefined as any}
onSelectionCallback={undefined as unknown as () => void}
/>
</MemoryRouter>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "t"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
0,
callback,
document.createElement("input"),
Expand All @@ -22,7 +22,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowDown"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
0,
callback,
null,
Expand All @@ -37,7 +37,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowDown"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
0,
callback,
document.createElement("input"),
Expand All @@ -53,7 +53,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowDown"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
-1,
callback,
inputElement,
Expand All @@ -71,7 +71,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowUp"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
1,
callback,
inputElement,
Expand All @@ -89,7 +89,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowDown"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
1,
callback,
inputElement,
Expand All @@ -105,7 +105,7 @@ describe("ArrowKeyDown", () => {
ArrowKeyDown(
{
key: "ArrowUp"
} as any,
} as React.KeyboardEvent<HTMLInputElement>,
0,
callback,
inputElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe("inline-search-suggest", () => {
inputFormControlReference: {
current: {
value: "default text"
} as any
},
}
} as React.RefObject<HTMLInputElement>,
featuresResult: { data: { systemTrashEnabled: true }, statusCode: 200 },
defaultText: "default text",
callback: jest.fn()
Expand Down Expand Up @@ -56,8 +56,8 @@ describe("inline-search-suggest", () => {
inputFormControlReference: {
current: {
value: "default text"
} as any
},
}
} as React.RefObject<HTMLInputElement>,
featuresResult: {
data: { systemTrashEnabled: true },
statusCode: 200
Expand All @@ -76,8 +76,8 @@ describe("inline-search-suggest", () => {
inputFormControlReference: {
current: {
value: "default text"
} as any
},
}
} as React.RefObject<HTMLInputElement>,
featuresResult: {
data: { useLocalDesktop: true },
statusCode: 200
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ILocationObject } from "../../../../hooks/use-location/interfaces/ILocationObject";
import { IUseLocation } from "../../../../hooks/use-location/interfaces/IUseLocation";
import { NavigateFunction } from "../../../../hooks/use-location/type/NavigateFunction";
import { UrlQuery } from "../../../../shared/url/url-query";
import Navigate from "./navigate";

describe("Navigate", () => {
const history: IUseLocation = {
navigate: jest.fn() as any,
location: {} as any
navigate: jest.fn() as unknown as NavigateFunction,
location: {} as ILocationObject
};
const setFormFocus = jest.fn();
const inputFormControlReference = { current: { value: "" } } as any;
const inputFormControlReference = { current: { value: "" } } as React.RefObject<HTMLInputElement>;
const query = "test query";
const callback = jest.fn();

Expand Down
Loading

0 comments on commit 81805c1

Please sign in to comment.