Skip to content

Commit 0609511

Browse files
committed
Test if scratch template is not displayed
1 parent 2e756c4 commit 0609511

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { render, screen } from "@testing-library/react";
2+
import StarterTemplatesPage from "./StarterTemplatesPage";
3+
import { AppProviders } from "App";
4+
import { RouterProvider, createMemoryRouter } from "react-router-dom";
5+
import { RequireAuth } from "contexts/auth/RequireAuth";
6+
import { rest } from "msw";
7+
import {
8+
MockTemplateExample,
9+
MockTemplateExample2,
10+
} from "testHelpers/entities";
11+
import { server } from "testHelpers/server";
12+
13+
test("does not display the scratch template", async () => {
14+
server.use(
15+
rest.get(
16+
"api/v2/organizations/:organizationId/templates/examples",
17+
(req, res, ctx) => {
18+
return res(
19+
ctx.status(200),
20+
ctx.json([
21+
MockTemplateExample,
22+
MockTemplateExample2,
23+
{
24+
...MockTemplateExample,
25+
id: "scratch",
26+
name: "Scratch",
27+
description: "Create a template from scratch",
28+
},
29+
]),
30+
);
31+
},
32+
),
33+
);
34+
35+
render(
36+
<AppProviders>
37+
<RouterProvider
38+
router={createMemoryRouter(
39+
[
40+
{
41+
element: <RequireAuth />,
42+
children: [
43+
{
44+
path: "/starter-templates",
45+
element: <StarterTemplatesPage />,
46+
},
47+
],
48+
},
49+
],
50+
{ initialEntries: ["/starter-templates"] },
51+
)}
52+
/>
53+
</AppProviders>,
54+
);
55+
56+
await screen.findByText(MockTemplateExample.name);
57+
screen.getByText(MockTemplateExample2.name);
58+
expect(screen.queryByText("Scratch")).not.toBeInTheDocument();
59+
});

0 commit comments

Comments
 (0)