Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3062814

Browse files
committed
Add tests
1 parent e7aec29 commit 3062814

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { screen } from "@testing-library/react"
2+
import {
3+
MockTemplateExample,
4+
MockTemplateExample2,
5+
renderWithAuth,
6+
waitForLoaderToBeRemoved,
7+
} from "testHelpers/renderHelpers"
8+
import StarterTemplatesPage from "./StarterTemplatesPage"
9+
10+
describe("StarterTemplatesPage", () => {
11+
it("shows the starter template", async () => {
12+
renderWithAuth(<StarterTemplatesPage />, {
13+
route: `/starter-templates`,
14+
path: "/starter-templates",
15+
})
16+
await waitForLoaderToBeRemoved()
17+
expect(screen.getByText(MockTemplateExample.name)).toBeInTheDocument()
18+
expect(screen.getByText(MockTemplateExample2.name)).toBeInTheDocument()
19+
})
20+
})

site/src/testHelpers/handlers.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ export const handlers = [
2424
rest.get("/api/v2/organizations/:organizationId", async (req, res, ctx) => {
2525
return res(ctx.status(200), ctx.json(M.MockOrganization))
2626
}),
27+
rest.get(
28+
"api/v2/organizations/:organizationId/templates/examples",
29+
(req, res, ctx) => {
30+
return res(
31+
ctx.status(200),
32+
ctx.json([M.MockTemplateExample, M.MockTemplateExample2]),
33+
)
34+
},
35+
),
2736
rest.get(
2837
"/api/v2/organizations/:organizationId/templates/:templateId",
2938
async (req, res, ctx) => {
@@ -266,14 +275,4 @@ export const handlers = [
266275
rest.get("/api/v2/workspace-quota/:userId", (req, res, ctx) => {
267276
return res(ctx.status(200), ctx.json(MockWorkspaceQuota))
268277
}),
269-
270-
rest.get(
271-
"api/v2/organizations/:organizationId/templates/examples",
272-
(req, res, ctx) => {
273-
return res(
274-
ctx.status(200),
275-
ctx.json([M.MockTemplateExample, M.MockTemplateExample2]),
276-
)
277-
},
278-
),
279278
]

0 commit comments

Comments
 (0)