-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathAnalyzedRepoItemContent.spec.tsx
More file actions
130 lines (117 loc) · 3.73 KB
/
AnalyzedRepoItemContent.spec.tsx
File metadata and controls
130 lines (117 loc) · 3.73 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import * as React from "react";
import { render as reactRender, screen } from "@testing-library/react";
import {
VariantAnalysisRepoStatus,
VariantAnalysisScannedRepositoryDownloadStatus,
} from "../../../variant-analysis/shared/variant-analysis";
import {
AnalyzedRepoItemContent,
AnalyzedRepoItemContentProps,
} from "../AnalyzedRepoItemContent";
import { ResultFormat } from "../../../variant-analysis/shared/variant-analysis-result-format";
describe(AnalyzedRepoItemContent.name, () => {
const render = (props: Partial<AnalyzedRepoItemContentProps> = {}) => {
return reactRender(
<AnalyzedRepoItemContent
status={VariantAnalysisRepoStatus.Succeeded}
resultFormat={ResultFormat.Alerts}
{...props}
/>,
);
};
it("renders the succeeded state with interpreted results", () => {
render({
status: VariantAnalysisRepoStatus.Succeeded,
interpretedResults: [
{
message: {
tokens: [
{
t: "text",
text: "This is an empty block.",
},
],
},
shortDescription: "This is an empty block.",
fileLink: {
fileLinkPrefix:
"https://github.com/facebook/create-react-app/blob/f34d88e30c7d8be7181f728d1abc4fd8d5cd07d3",
filePath: "packages/create-react-app/createReactApp.js",
},
severity: "Warning",
codeSnippet: {
startLine: 655,
endLine: 662,
text: " try {\n callback();\n } catch (ignored) {\n // Callback might throw and fail, since it's a temp directory the\n // OS will clean it up eventually...\n }\n },\n });\n",
},
highlightedRegion: {
startLine: 657,
startColumn: 31,
endLine: 660,
endColumn: 14,
},
codeFlows: [],
},
],
});
expect(screen.getByText("This is an empty block.")).toBeInTheDocument();
});
it("renders the succeeded state with raw results", () => {
render({
status: VariantAnalysisRepoStatus.Succeeded,
rawResults: {
schema: {
name: "#select",
rows: 1,
columns: [
{
kind: "i",
},
],
},
resultSet: {
schema: {
name: "#select",
rows: 1,
columns: [
{
kind: "i",
},
],
},
rows: [[60688]],
},
fileLinkPrefix:
"https://github.com/octodemo/hello-world-1/blob/59a2a6c7d9dde7a6ecb77c2f7e8197d6925c143b",
sourceLocationPrefix: "/home/runner/work/bulk-builder/bulk-builder",
capped: false,
},
});
expect(screen.getByText("60688")).toBeInTheDocument();
});
it("renders the failed state", () => {
render({
status: VariantAnalysisRepoStatus.Failed,
});
expect(screen.getByText("Error: Failed")).toBeInTheDocument();
});
it("renders the timed out state", () => {
render({
status: VariantAnalysisRepoStatus.TimedOut,
});
expect(screen.getByText("Error: Timed out")).toBeInTheDocument();
});
it("renders the canceled state", () => {
render({
status: VariantAnalysisRepoStatus.Canceled,
});
expect(screen.getByText("Error: Canceled")).toBeInTheDocument();
});
it("renders the failed download state", () => {
render({
status: VariantAnalysisRepoStatus.Succeeded,
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Failed,
});
expect(screen.getByText("Error: Download failed")).toBeInTheDocument();
});
});