Skip to content

Commit 6c3b0b5

Browse files
authored
Move AnalysisAlert mock creation to a factory module (#3493)
1 parent e7d2a59 commit 6c3b0b5

2 files changed

Lines changed: 35 additions & 29 deletions

File tree

extensions/ql-vscode/src/stories/variant-analysis/AnalysisAlertResult.stories.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryFn } from "@storybook/react";
22

33
import AnalysisAlertResult from "../../view/variant-analysis/AnalysisAlertResult";
44
import type { AnalysisAlert } from "../../variant-analysis/shared/analysis-result";
5+
import { createMockAnalysisAlert } from "../../../test/factories/variant-analysis/shared/analysis-alert";
56

67
export default {
78
title: "Variant Analysis/Analysis Alert Result",
@@ -14,35 +15,7 @@ const Template: StoryFn<typeof AnalysisAlertResult> = (args) => (
1415

1516
export const Warning = Template.bind({});
1617

17-
const warningAlert: AnalysisAlert = {
18-
message: {
19-
tokens: [
20-
{
21-
t: "text",
22-
text: "This is an empty block.",
23-
},
24-
],
25-
},
26-
shortDescription: "This is an empty block.",
27-
fileLink: {
28-
fileLinkPrefix:
29-
"https://github.com/expressjs/express/blob/33e8dc303af9277f8a7e4f46abfdcb5e72f6797b",
30-
filePath: "test/app.options.js",
31-
},
32-
severity: "Warning",
33-
codeSnippet: {
34-
startLine: 10,
35-
endLine: 14,
36-
text: " app.del('/', function(){});\n app.get('/users', function(req, res){});\n app.put('/users', function(req, res){});\n\n request(app)\n",
37-
},
38-
highlightedRegion: {
39-
startLine: 12,
40-
startColumn: 41,
41-
endLine: 12,
42-
endColumn: 43,
43-
},
44-
codeFlows: [],
45-
};
18+
const warningAlert: AnalysisAlert = createMockAnalysisAlert();
4619

4720
Warning.args = {
4821
alert: warningAlert,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { AnalysisAlert } from "../../../../src/variant-analysis/shared/analysis-result";
2+
3+
export function createMockAnalysisAlert(): AnalysisAlert {
4+
return {
5+
message: {
6+
tokens: [
7+
{
8+
t: "text",
9+
text: "This is an empty block.",
10+
},
11+
],
12+
},
13+
shortDescription: "This is an empty block.",
14+
fileLink: {
15+
fileLinkPrefix:
16+
"https://github.com/expressjs/express/blob/33e8dc303af9277f8a7e4f46abfdcb5e72f6797b",
17+
filePath: "test/app.options.js",
18+
},
19+
severity: "Warning",
20+
codeSnippet: {
21+
startLine: 10,
22+
endLine: 14,
23+
text: " app.del('/', function(){});\n app.get('/users', function(req, res){});\n app.put('/users', function(req, res){});\n\n request(app)\n",
24+
},
25+
highlightedRegion: {
26+
startLine: 12,
27+
startColumn: 41,
28+
endLine: 12,
29+
endColumn: 43,
30+
},
31+
codeFlows: [],
32+
};
33+
}

0 commit comments

Comments
 (0)