import React from "react"; import { render, screen } from "@testing-library/react"; import { noop } from "lodash"; // TODOL Replace renderWithAppContext with createCustomRenderer import { renderWithAppContext } from "test/test-utils"; import TeamsDropdown from "./TeamsDropdown"; describe("TeamsDropdown - component", () => { const USER_TEAMS = [ { id: 1, name: "Team 1" }, { id: 2, name: "Team 2" }, ]; it("renders the given selected team from selectedTeamId", () => { render( ); const selectedTeam = screen.getByText("Team 1"); expect(selectedTeam).toBeInTheDocument(); }); it("renders the first team option when includeAll is false and when no selectedTeamId is given", () => { render( ); const selectedTeam = screen.getByText("Team 1"); expect(selectedTeam).toBeInTheDocument(); }); describe("user is on the global team", () => { const contextValue = { isOnGlobalTeam: true, }; it("renders 'All teams' when no selectedTeamId is given", () => { renderWithAppContext( , { contextValue } ); const selectedTeam = screen.getByText("All teams"); expect(selectedTeam).toBeInTheDocument(); }); it("renders the first team option when includeAll is false and when no selectedTeamId is given", () => { renderWithAppContext( , { contextValue } ); const selectedTeam = screen.getByText("Team 1"); expect(selectedTeam).toBeInTheDocument(); }); }); describe("user is not on the global team", () => { const contextValue = { isOnGlobalTeam: false }; it("renders the first team when no selectedTeamId is given", () => { renderWithAppContext( , { contextValue } ); expect(screen.getByText("Team 1")).toBeInTheDocument(); }); }); });