-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#705 Fix routing in team management and fix tests
- Loading branch information
mkaeser2
committed
Jan 10, 2024
1 parent
ca6e0f7
commit 20f622b
Showing
6 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {getRouteToTeam, getRouteToUserDetails} from "./routeUtils"; | ||
|
||
describe('routeUtils', () => { | ||
describe('getRouteToUserDetails', () => { | ||
|
||
it("should not include team fragment when teamId is missing", () => { | ||
expect(getRouteToUserDetails(1)).toBe(`/team-management/details/member/1`); | ||
}); | ||
|
||
it("should include team fragment when teamId is missing", () => { | ||
expect(getRouteToUserDetails(1, 11)).toBe(`/team-management/11/details/member/1`); | ||
}); | ||
|
||
|
||
it("should work with id=0", () => { | ||
expect(getRouteToUserDetails(0, 0)).toBe(`/team-management/0/details/member/0`); | ||
}); | ||
|
||
}) | ||
|
||
describe('getRouteToTeam', () => { | ||
|
||
it("should work with normal id", () => { | ||
expect(getRouteToTeam(1)).toBe(`/team-management/1`); | ||
}); | ||
|
||
|
||
it("should work with id=0", () => { | ||
expect(getRouteToTeam(0)).toBe(`/team-management/0`); | ||
}); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export const getRouteToUserDetails = (userId: number) => 'details/member/' + userId; | ||
export const getRouteToTeam = (teamId: number) => '/team-management/' + teamId; | ||
export const getRouteToUserDetails = (userId: number, teamId?: number) => { | ||
const teamFragment = teamId !== undefined ? `/${teamId}` : ''; | ||
return `/team-management${teamFragment}/details/member/${userId}`; | ||
}; | ||
export const getRouteToTeam = (teamId: number) => `/team-management/${teamId}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters