Skip to content

Commit

Permalink
add test && rename && add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Feb 4, 2024
1 parent bf6137d commit 50a50ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const CurrentLocationButton: React.FunctionComponent<CurrentLocationButtonPropTy
setError(true);
return;
}
// typescript:S5604 - is used to get the current position of the device
navigator.geolocation.getCurrentPosition(currentPositionSuccess, currentPositionError);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { GetFilterUrlColorClass } from "./get-filter-url-color-class";
import { IArchiveProps } from "../../../../interfaces/IArchiveProps";
import { IFileIndexItem, newIFileIndexItem } from "../../../../interfaces/IFileIndexItem";

describe("GetFilterUrlColorClass", () => {
it("get colorClass back", () => {
// Mock necessary dependencies
const historyLocationSearch = "your-history-location-search";
const state = {
fileIndexItems: {}
} as IArchiveProps;

// Call the function
const result = GetFilterUrlColorClass(1, historyLocationSearch, state);

// Assertions
expect(result).toBe("?colorClass=1");
});

it("get select back", () => {
// Mock necessary dependencies
const historyLocationSearch = "?select=test.jpg";
const state = {
fileIndexItems: [
{
...newIFileIndexItem(),
fileName: "test.jpg",
colorClass: 1
} as IFileIndexItem
]
} as IArchiveProps;

// Call the function
const result = GetFilterUrlColorClass(1, historyLocationSearch, state);

// Assertions
expect(result).toBe("?select=test.jpg&colorClass=1");
});
});
10 changes: 5 additions & 5 deletions starsky/starsky/clientapp/src/shared/select-check-if-active.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { IFileIndexItem } from "../interfaces/IFileIndexItem";
import {IFileIndexItem} from "../interfaces/IFileIndexItem";

export class SelectCheckIfActive {
public IsActive(
select: string[] | undefined,
colorclasses: number[],
colorClasses: number[],
fileIndexItems: IFileIndexItem[]
) {
if (!select) return [];

// it should contain on the colorclasses
// it should contain on the colorClasses
const fileNameList = fileIndexItems
.filter((el) => el.colorClass !== undefined && colorclasses.indexOf(el.colorClass) !== -1)
.filter((el) => el.colorClass !== undefined && colorClasses.indexOf(el.colorClass) !== -1)
.map((ele) => ele.fileName);

// you can't select an item thats not shown
// you can't select an item that's not shown
select.forEach((selectedPath) => {
if (fileNameList.indexOf(selectedPath) === -1) {
const selectIndex = select.indexOf(selectedPath);
Expand Down

0 comments on commit 50a50ad

Please sign in to comment.