This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix namespace selector and add test coverage
Signed-off-by: Jordan Pellizzari <jordan@weave.works>
- Loading branch information
1 parent
f48d23e
commit 805b123
Showing
9 changed files
with
550 additions
and
17 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import "jest-styled-components"; | ||
import { stubbedClustersResponses, withContext } from "../../lib/test-utils"; | ||
import TopNav from "../TopNav"; | ||
|
||
describe("TopNav", () => { | ||
let container; | ||
beforeEach(() => { | ||
container = document.createElement("div"); | ||
document.body.appendChild(container); | ||
}); | ||
afterEach(() => { | ||
document.body.removeChild(container); | ||
container = null; | ||
}); | ||
|
||
describe("snapshots", () => { | ||
it("renders", async () => { | ||
const url = "/?context=my-context&namespace=default"; | ||
|
||
const tree = render(withContext(TopNav, url, stubbedClustersResponses)); | ||
expect((await screen.findByText("my-context")).textContent).toBeTruthy(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
it("sets the current context", async () => { | ||
const url = "/?context=my-context&namespace=default"; | ||
|
||
render(withContext(TopNav, url, stubbedClustersResponses)); | ||
|
||
const input = await screen.findByDisplayValue("my-context"); | ||
|
||
expect(input).toBeTruthy(); | ||
}); | ||
it("sets the current namespace", async () => { | ||
const ns = "some-ns"; | ||
const url = `/?context=my-context&namespace=${ns}`; | ||
|
||
render( | ||
withContext(TopNav, url, { | ||
...stubbedClustersResponses, | ||
listNamespacesForContext: { namespaces: [ns] }, | ||
}) | ||
); | ||
|
||
const input = await screen.findByDisplayValue(ns); | ||
expect(input).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.