Skip to content

Commit 35e1a21

Browse files
author
Arvid Paeglit
committed
fixes in tests
1 parent 21fabc9 commit 35e1a21

2 files changed

Lines changed: 6 additions & 62 deletions

File tree

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@
233233
"@types/glob": "^7.1.3",
234234
"@types/lodash": "^4.14.161",
235235
"@types/mocha": "^8.0.3",
236-
"@types/nock": "^11.1.0",
237236
"@types/node": "^14.6.2",
238237
"@types/vscode": "^1.48.0",
239238
"@typescript-eslint/eslint-plugin": "^4.0.1",
@@ -245,10 +244,10 @@
245244
"eslint-plugin-prettier": "^3.1.4",
246245
"glob": "^7.1.6",
247246
"mocha": "^8.1.3",
248-
"nock": "^13.0.4",
249247
"prettier": "^2.1.1",
250248
"typescript": "^4.0.2",
251-
"vscode-test": "^1.4.0"
249+
"vscode-test": "^1.4.0",
250+
"yalc": "^1.0.0-pre.44"
252251
},
253252
"dependencies": {
254253
"@deepcode/tsc": "file:.yalc/@deepcode/tsc",

src/test/suite/extension.test.ts

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,14 @@
44
//
55
import * as assert from "assert";
66
import * as vscode from "vscode";
7-
import * as path from "path";
8-
import nock from "nock";
7+
import * as nodePath from 'path';
98
//
109
import * as extension from "../../extension";
1110
import { ExtensionInterface } from "../../interfaces/DeepCodeInterfaces";
1211

13-
// mocked data for tests
14-
const testHost = "http://localhost:3000";
15-
const testHostPrefix = "/publicapi";
16-
const testToken = "TEST_TOKEN";
17-
const testBundleId = "testBundleId";
1812
const mockedTestFilesDirPath = __dirname.replace("out/test", "src/test");
19-
const mockedFolderPath = vscode.Uri.parse(
20-
"scheme:" + path.join(mockedTestFilesDirPath, "/../mocked_data"),
21-
true
22-
).fsPath;
23-
24-
// mocked server
25-
const mockedServer = nock(`${testHost}${testHostPrefix}`, {
26-
reqheaders: {
27-
"Session-Token": testToken
28-
}
29-
});
30-
// mocked server responses
31-
const mockedServerBundleWithMissingFiles = {
32-
statusCode: 200,
33-
bundleId: testBundleId,
34-
missingFiles: ["/sample_repository/sub_folder/test2.js"]
35-
};
36-
const mockedCheckedBundle = { statusCode: 200, bundleId: testBundleId };
37-
const mockedFilesFiltersResponse = { extensions: [".js"], configFiles: [] };
38-
const mockedAnalysisResults = {
39-
status: "DONE",
40-
progress: 1.0,
41-
analysisResults: {
42-
files: { "/main.js": { "0": [{ rows: [1, 2], cols: [3, 4] }] } },
43-
suggestions: {
44-
"0": { message: "some message", severity: 1 }
45-
}
46-
},
47-
analysisURL: "test_analysis_url"
48-
};
49-
// mocked endpoints
50-
mockedServer.get('/session').query(true).reply(200, { type: "private" });
51-
mockedServer.get('/filters').reply(200, mockedFilesFiltersResponse);
52-
mockedServer
53-
.post("/bundle")
54-
.matchHeader("Content-Type", "application/json")
55-
.reply(200, mockedServerBundleWithMissingFiles);
56-
mockedServer
57-
.post(`/file/${testBundleId}`)
58-
.matchHeader("Content-Type", "application/json;charset=utf-8")
59-
.reply(200);
60-
mockedServer.get(`/bundle/${testBundleId}`).reply(200, mockedCheckedBundle);
61-
mockedServer.get(`/analysis/${testBundleId}`).reply(200, mockedAnalysisResults);
13+
const mockedFolderPath = vscode.Uri.parse('scheme:' + nodePath.join(mockedTestFilesDirPath, '/../mocked_data'), true)
14+
.fsPath;
6215

6316
// pre test configuring extension
6417
const preTestConfigureExtension = () => {
@@ -76,17 +29,9 @@ const preTestConfigureExtension = () => {
7629
return testExtension;
7730
};
7831

79-
const uri = vscode.Uri.file(
80-
path.join(mockedTestFilesDirPath, "../mocked_data/sample_repository", "main.js"),
81-
);
32+
const uri = vscode.Uri.file(nodePath.join(mockedTestFilesDirPath, '../mocked_data/sample_repository', 'main.js'));
8233

8334
const testIgnoreComment = ' // deepcode ignore UseStrictEquality: <please specify a reason of ignoring this>\n';
84-
const testFilesList = [
85-
'/../mocked_data/sample_repository/utf8.js',
86-
'/../mocked_data/sample_repository/main.js',
87-
'/../mocked_data/sample_repository/sub_folder/test2.js',
88-
'/../mocked_data/test.java',
89-
];
9035

9136
suite("Deepcode Extension Tests", () => {
9237
let testExtension: ExtensionInterface;

0 commit comments

Comments
 (0)