8000 test! · coder/coder@132bc79 · GitHub
[go: up one dir, main page]

Skip to content

Commit 132bc79

Browse files
committed
test!
1 parent f8b48f9 commit 132bc79

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { API } from "api/api";
2+
import * as M from "testHelpers/entities";
3+
import { TemplateRedirectController } from "./TemplateRedirectController";
4+
import { renderWithAuth } from "testHelpers/renderHelpers";
5+
import { waitFor } from "@testing-library/react";
6+
7+
const renderTemplateRedirectController = (route: string) => {
8+
return renderWithAuth(<TemplateRedirectController />, {
9+
route,
10+
path: "/templates/:organization?/:template",
11+
});
12+
};
13+
14+
it("redirects from multi-org to single-org", async () => {
15+
const page = renderTemplateRedirectController(
16+
`/templates/${M.MockTemplate.organization_name}/${M.MockTemplate.name}`,
17+
);
18+
19+
await waitFor(() =>
20+
expect(page.router.state.location.pathname).toEqual(
21+
`/templates/${M.MockTemplate.name}`,
22+
),
23+
);
24+
});
25+
26+
it("redirects from single-org to multi-org", async () => {
27+
jest
28+
.spyOn(API, "getOrganizations")
29+
.mockResolvedValueOnce([M.MockDefaultOrganization, M.MockOrganization2]);
30+
31+
const page = renderTemplateRedirectController(
32+
`/templates/${M.MockTemplate.name}`,
33+
);
34+
35+
await waitFor(() =>
36+
expect(page.router.state.location.pathname).toEqual(
37+
`/templates/${M.MockDefaultOrganization.name}/${M.MockTemplate.name}`,
38+
),
39+
);
40+
});

0 commit comments

Comments
 (0)
0