-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Darshan Simha <darshan_simha@intuit.com> Co-authored-by: Darshan Simha <darshan_simha@intuit.com>
- Loading branch information
Showing
7 changed files
with
218 additions
and
144 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,52 @@ | ||
import React from "react"; | ||
import { fireEvent, render, screen, waitFor } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
|
||
import AccountMenu from "./index"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { AppContext } from "../../../App"; | ||
import { act } from "react-dom/test-utils"; | ||
|
||
jest.mock("react-router-dom", () => ({ | ||
...jest.requireActual("react-router-dom"), | ||
useNavigate: () => jest.fn(), | ||
})); | ||
|
||
describe("AccountMenu", () => { | ||
const mockContext = { | ||
userInfo: { | ||
name: "John Doe", | ||
email: "john.doe@example.com", | ||
}, | ||
}; | ||
|
||
const mockNavigate = jest.fn(); | ||
|
||
it("renders", async () => { | ||
render( | ||
<BrowserRouter> | ||
<AppContext.Provider value={mockContext}> | ||
<AccountMenu /> | ||
</AppContext.Provider> | ||
</BrowserRouter> | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByTestId("account-menu")).toBeInTheDocument(); | ||
}); | ||
}); | ||
it("logs out", async () => { | ||
render( | ||
<BrowserRouter> | ||
<AppContext.Provider value={mockContext}> | ||
<AccountMenu /> | ||
</AppContext.Provider> | ||
</BrowserRouter> | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByText("Log out")).toBeInTheDocument(); | ||
}); | ||
await act(async () => { | ||
fireEvent.click(screen.getByText("Log out")); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,69 @@ | ||
// import { Breadcrumbs } from "./index"; | ||
// import { render, screen } from "@testing-library/react"; | ||
// import { BrowserRouter } from "react-router-dom"; | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import { MemoryRouter, Route, Routes } from "react-router-dom"; | ||
import { AppContext } from "../../../App"; | ||
import { Breadcrumbs } from "./index"; | ||
|
||
import "@testing-library/jest-dom" | ||
describe("Breadcrumbs", () => { | ||
const mockContext = { | ||
systemInfo: { | ||
namespaced: true, | ||
}, | ||
}; | ||
|
||
// let mockPATH = ""; | ||
it("renders the breadcrumbs", () => { | ||
const { getByTestId } = render( | ||
<MemoryRouter initialEntries={["/"]}> | ||
<AppContext.Provider value={mockContext}> | ||
<Breadcrumbs /> | ||
</AppContext.Provider> | ||
</MemoryRouter> | ||
); | ||
|
||
// jest.mock("react-router-dom", () => ({ | ||
// ...jest.requireActual("react-router-dom"), | ||
// useLocation: () => ({ | ||
// pathname: mockPATH, | ||
// }), | ||
// })); | ||
expect(getByTestId("mui-breadcrumbs")).toBeInTheDocument(); | ||
}); | ||
|
||
describe("Breadcrumbs", () => { | ||
test.todo('please update'); | ||
// it("loads namespace screen", () => { | ||
// mockPATH = "/"; | ||
// render( | ||
// <BrowserRouter> | ||
// <Breadcrumbs /> | ||
// </BrowserRouter> | ||
// ); | ||
// expect(screen.getByTestId("namespace-breadcrumb")).toBeInTheDocument(); | ||
// expect(screen.getByTestId("mui-breadcrumbs")).toBeInTheDocument(); | ||
// }); | ||
it("displays the correct breadcrumbs for a namespace summary view", () => { | ||
const { getByTestId, getByText } = render( | ||
<MemoryRouter initialEntries={["/"]}> | ||
<AppContext.Provider value={mockContext}> | ||
<Breadcrumbs /> | ||
<Routes> | ||
<Route | ||
exact | ||
path="/" | ||
render={() => <div>Namespace summary view</div>} | ||
/> | ||
</Routes> | ||
</AppContext.Provider> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(getByTestId("namespace-breadcrumb")).toBeInTheDocument(); | ||
expect(getByText("Namespace")).toBeInTheDocument(); | ||
}); | ||
|
||
// it("loads pipeline screen", () => { | ||
// mockPATH = "/namespaces/numaflow-system/pipelines/simple-pipeline"; | ||
// render( | ||
// <BrowserRouter> | ||
// <Breadcrumbs /> | ||
// </BrowserRouter> | ||
// ); | ||
// expect(screen.getByTestId("pipeline-breadcrumb")).toBeInTheDocument(); | ||
// expect(screen.getByTestId("mui-breadcrumbs")).toBeInTheDocument(); | ||
// }); | ||
it("displays the correct breadcrumbs for a pipeline summary view", () => { | ||
const { getByTestId, getByText } = render( | ||
<MemoryRouter | ||
initialEntries={["/namespaces/test/pipelines/test-pipeline"]} | ||
> | ||
<AppContext.Provider value={mockContext}> | ||
<Breadcrumbs /> | ||
<Routes> | ||
{" "} | ||
<Route | ||
exact | ||
path="/namespaces/:namespace/pipelines/:pipeline" | ||
render={() => <div>Pipeline summary view</div>} | ||
/> | ||
</Routes> | ||
</AppContext.Provider> | ||
</MemoryRouter> | ||
); | ||
|
||
// it("loads pipeline screen", () => { | ||
// mockPATH = "/random"; | ||
// render( | ||
// <BrowserRouter> | ||
// <Breadcrumbs /> | ||
// </BrowserRouter> | ||
// ); | ||
// expect(screen.getByTestId("unknown-breadcrumb")).toBeInTheDocument(); | ||
// expect(screen.getByTestId("mui-breadcrumbs")).toBeInTheDocument(); | ||
// }); | ||
expect(getByTestId("unknown-breadcrumb")).toBeInTheDocument(); | ||
expect(getByText("Unknown")).toBeInTheDocument(); | ||
expect(getByTestId("mui-breadcrumbs")).toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.