Skip to content

Commit 35e7016

Browse files
committed
simple tests
1 parent fd3cd9b commit 35e7016

File tree

5 files changed

+96
-93
lines changed

5 files changed

+96
-93
lines changed

package-lock.json

Lines changed: 4 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@
103103
"scheme": {
104104
"type": "string",
105105
"description": "Protocol used for connections.",
106-
"enum": ["http", "https"],
106+
"enum": [
107+
"http",
108+
"https"
109+
],
107110
"default": "http"
108111
},
109112
"host": {
@@ -134,7 +137,10 @@
134137
"description": "Optional prefix for the path to the resource. Only needed when one web server publishes services on behalf of multiple InterSystems® servers."
135138
}
136139
},
137-
"required": ["host", "port"],
140+
"required": [
141+
"host",
142+
"port"
143+
],
138144
"additionalProperties": false
139145
},
140146
"username": {
@@ -150,15 +156,17 @@
150156
"description": "Optional description of the server."
151157
}
152158
},
153-
"required": ["webServer"],
159+
"required": [
160+
"webServer"
161+
],
154162
"additionalProperties": false
155163
}
156164
},
157165
"properties": {
158166
"/default": {
159167
"type": "string",
160168
"description": "Name of the default server."
161-
}
169+
}
162170
},
163171
"additionalProperties": false
164172
}

test/runTest.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as path from "path";
2+
3+
import { runTests } from "vscode-test";
4+
5+
async function main() {
6+
try {
7+
// The folder containing the Extension Manifest package.json
8+
// Passed to `--extensionDevelopmentPath`
9+
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
10+
11+
// The path to the extension test script
12+
// Passed to --extensionTestsPath
13+
const extensionTestsPath = path.resolve(__dirname, "./suite/index");
14+
15+
const launchArgs = ["--enable-proposed-api", "intersystems.servermanager"];
16+
17+
// Download VS Code, unzip it and run the integration test
18+
await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs });
19+
} catch (err) {
20+
console.error("Failed to run tests", err);
21+
process.exit(1);
22+
}
23+
}
24+
25+
main();

test/suite/extension.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as assert from "assert";
2+
import { before } from "mocha";
3+
4+
// You can import and use all API from the 'vscode' module
5+
// as well as import your extension to test it
6+
import * as vscode from "vscode";
7+
// import * as myExtension from '../extension';
8+
9+
suite("Extension Test Suite", () => {
10+
before(() => {
11+
vscode.window.showInformationMessage("Start all tests.");
12+
});
13+
14+
test("Sample test", () => {
15+
assert.equal([1, 2, 3].indexOf(5), -1);
16+
assert.equal([1, 2, 3].indexOf(0), -1);
17+
});
18+
});

test/suite/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as path from "path";
2+
import * as Mocha from "mocha";
3+
import * as glob from "glob";
4+
5+
export function run(): Promise<void> {
6+
// Create the mocha test
7+
const mocha = new Mocha({
8+
ui: "tdd",
9+
});
10+
mocha.useColors(true);
11+
12+
const testsRoot = path.resolve(__dirname, "..");
13+
14+
return new Promise((c, e) => {
15+
glob("**/**.test.js", { cwd: testsRoot }, (err, files) => {
16+
if (err) {
17+
return e(err);
18+
}
19+
20+
// Add files to the test suite
21+
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22+
23+
try {
24+
// Run the mocha test
25+
mocha.run(failures => {
26+
if (failures > 0) {
27+
e(new Error(`${failures} tests failed.`));
28+
} else {
29+
c();
30+
}
31+
});
32+
} catch (err) {
33+
e(err);
34+
}
35+
});
36+
});
37+
}

0 commit comments

Comments
 (0)