Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabib committed Jan 14, 2025
1 parent 0319633 commit 09c4b93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/portfolio.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const getTopProjects = ({
maxResults?: number;
isSignedIn?: boolean;
}): TableProject[] => {
const topProjects = projects.sort(compareProjects).slice(0, maxResults);
const topProjects = [...projects].sort(compareProjects).slice(0, maxResults);

if (!isSignedIn) return topProjects;

Expand Down
15 changes: 11 additions & 4 deletions frontend/src/tests/lib/utils/portfolio.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,28 @@ describe("Portfolio utils", () => {
const mockIcpProject: TableProject = {
...mockTableProject,
title: "Internet Computer",
stakeInUsd: 100,
stakeInUsd: 0,
};

const mockProject1: TableProject = {
...mockTableProject,
title: "Alpha Project",
stakeInUsd: 50,
stakeInUsd: 0,
universeId: "1",
};

const mockProject2: TableProject = {
...mockTableProject,
title: "Beta Project",
stakeInUsd: 25,
stakeInUsd: 0,
universeId: "2",
};

const mockProject3: TableProject = {
...mockTableProject,
title: "Gamma Project",
stakeInUsd: 10,
stakeInUsd: 0,
universeId: "3",
};

it("should respect the result limit", () => {
Expand Down Expand Up @@ -226,24 +229,28 @@ describe("Portfolio utils", () => {
...mockTableProject,
title: "Alpha Project",
stakeInUsd: 2000,
universeId: "1",
};

const mockProject2: TableProject = {
...mockTableProject,
title: "Beta Project",
stakeInUsd: 1000,
universeId: "2",
};

const mockProject3: TableProject = {
...mockTableProject,
title: "Gamma Project",
stakeInUsd: 10,
universeId: "3",
};

const mockZeroStakeProject: TableProject = {
...mockTableProject,
title: "Zero Stake Project",
stakeInUsd: 0,
universeId: "4",
};

it("should exclude projects with zero stake", () => {
Expand Down

0 comments on commit 09c4b93

Please sign in to comment.