forked from github/vscode-codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodePaths.spec.tsx
48 lines (39 loc) · 1.46 KB
/
CodePaths.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { render as reactRender, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import type { CodePathsProps } from "../CodePaths";
import { CodePaths } from "../CodePaths";
import { createMockCodeFlows } from "../../../../../test/factories/variant-analysis/shared/CodeFlow";
import { createMockAnalysisMessage } from "../../../../../test/factories/variant-analysis/shared/AnalysisMessage";
describe(CodePaths.name, () => {
const render = (props?: CodePathsProps) =>
reactRender(
<CodePaths
codeFlows={createMockCodeFlows()}
ruleDescription="Rule description"
message={createMockAnalysisMessage()}
severity="Recommendation"
{...props}
/>,
);
it("renders 'show paths' link", () => {
render();
expect(screen.getByText("Show paths")).toBeInTheDocument();
});
it("renders shortest path for code flows", () => {
render();
expect(screen.getByText("(Shortest: 1)")).toBeInTheDocument();
});
it("posts extension message when 'show paths' link clicked", async () => {
render();
await userEvent.click(screen.getByText("Show paths"));
expect(window.vsCodeApi.postMessage).toHaveBeenCalledWith({
t: "showDataFlowPaths",
dataFlowPaths: {
codeFlows: createMockCodeFlows(),
ruleDescription: "Rule description",
message: createMockAnalysisMessage(),
severity: "Recommendation",
},
});
});
});