-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add team sidebar display conditions (#689)
- Loading branch information
Showing
2 changed files
with
88 additions
and
5 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 |
---|---|---|
|
@@ -2,15 +2,60 @@ import React from "react"; | |
import { render, screen } from "@testing-library/react"; | ||
import Sidebar from "../"; | ||
import { EpisodeIdContext } from "../../../contexts/EpisodeContext"; | ||
import { CurrentUserContext } from "../../../contexts/CurrentUserContext"; | ||
import { | ||
CurrentTeamContext, | ||
TeamStateEnum, | ||
} from "../../../contexts/CurrentTeamContext"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import { Status526Enum } from "../../../utils/types"; | ||
|
||
const mem = { | ||
id: 123, | ||
username: "theuser", | ||
is_staff: false, | ||
}; | ||
const faketeam = { | ||
id: 123, | ||
episode: "bc23", | ||
name: "theteam", | ||
members: [mem], | ||
join_key: "abc", | ||
status: Status526Enum.O, | ||
}; | ||
const fakeuser = { | ||
id: 123, | ||
username: "theuser", | ||
email: "[email protected]", | ||
first_name: "the", | ||
last_name: "user", | ||
is_staff: false, | ||
}; | ||
|
||
test("UI: should collapse sidebar", () => { | ||
render( | ||
<MemoryRouter> | ||
<EpisodeIdContext.Provider | ||
value={{ episodeId: "something", setEpisodeId: (_) => undefined }} | ||
> | ||
<Sidebar collapsed={true} /> | ||
<CurrentTeamContext.Provider | ||
value={{ teamState: TeamStateEnum.IN_TEAM, team: faketeam }} | ||
> | ||
<CurrentUserContext.Provider | ||
value={{ | ||
authState: "loading", | ||
user: fakeuser, | ||
login: (_) => { | ||
console.log(); | ||
}, | ||
logout: () => { | ||
console.log(); | ||
}, | ||
}} | ||
> | ||
<Sidebar collapsed={true} /> | ||
</CurrentUserContext.Provider> | ||
</CurrentTeamContext.Provider> | ||
</EpisodeIdContext.Provider> | ||
</MemoryRouter>, | ||
); | ||
|
@@ -23,7 +68,24 @@ test("UI: should link to episode in surrounding context", () => { | |
<EpisodeIdContext.Provider | ||
value={{ episodeId: "something", setEpisodeId: (_) => undefined }} | ||
> | ||
<Sidebar /> | ||
<CurrentTeamContext.Provider | ||
value={{ teamState: TeamStateEnum.IN_TEAM, team: faketeam }} | ||
> | ||
<CurrentUserContext.Provider | ||
value={{ | ||
authState: "loading", | ||
user: fakeuser, | ||
login: (_) => { | ||
console.log(); | ||
}, | ||
logout: () => { | ||
console.log(); | ||
}, | ||
}} | ||
> | ||
<Sidebar /> | ||
</CurrentUserContext.Provider> | ||
</CurrentTeamContext.Provider> | ||
</EpisodeIdContext.Provider> | ||
</MemoryRouter>, | ||
); | ||
|
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