Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
fix unit test error 'cannot find vscode module' #2311 (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
taseri authored and ramya-rao-a committed Feb 12, 2019
1 parent 98f0874 commit 056a756
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ install:

script:
- npm run lint
- npm run unit-test
- npm test --silent
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"preLaunchTask": "npm"
},
{
"name": "Launch Tests",
"name": "Launch Integration Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
Expand All @@ -42,7 +42,7 @@
{
"type": "node",
"request": "launch",
"name": "Unit Tests",
"name": "Launch Unit Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test",
"lint": "node ./node_modules/tslint/bin/tslint ./src/*.ts ./src/debugAdapter/*.ts ./test/*.ts"
"lint": "node ./node_modules/tslint/bin/tslint ./src/*.ts ./src/debugAdapter/*.ts ./test/*.ts",
"unit-test": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 --colors ./out/test/unit"
},
"extensionDependencies": [],
"dependencies": {
Expand Down Expand Up @@ -1367,4 +1368,4 @@
]
}
}
}
}
40 changes: 20 additions & 20 deletions test/unit/utils.test.ts → test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------*/

import { guessPackageNameFromFile } from "../../src/util";
import * as assert from "assert";
import { substituteEnv } from "../../src/util";
import { guessPackageNameFromFile } from '../src/util';
import * as assert from 'assert';
import { substituteEnv } from '../src/util';

suite("utils Tests", () => {
test("substituteEnv: default", () => {
suite('utils Tests', () => {
test('substituteEnv: default', () => {
// prepare test
const env = Object.assign({}, process.env);
process.env["test1"] = "abcd";
process.env["test2"] = "defg";
process.env['test1'] = 'abcd';
process.env['test2'] = 'defg';

let actual = substituteEnv(
" ${env:test1} \r\n ${env:test2}\r\n${env:test1}"
' ${env:test1} \r\n ${env:test2}\r\n${env:test1}'
);
let expected = " abcd \r\n defg\r\nabcd";
let expected = ' abcd \r\n defg\r\nabcd';

assert.equal(actual, expected);

Expand All @@ -26,10 +26,10 @@ suite("utils Tests", () => {
});
});

suite("GuessPackageNameFromFile Tests", () => {
test("package name from main file", done => {
const expectedPackageName = "main";
const filename = "main.go";
suite('GuessPackageNameFromFile Tests', () => {
test('package name from main file', done => {
const expectedPackageName = 'main';
const filename = 'main.go';

guessPackageNameFromFile(filename)
.then(result => {
Expand All @@ -38,9 +38,9 @@ suite("GuessPackageNameFromFile Tests", () => {
.then(() => done(), done);
});

test("package name from dirpath", done => {
const expectedPackageName = "package";
const fileDir = "path/package/file.go";
test('package name from dirpath', done => {
const expectedPackageName = 'package';
const fileDir = 'path/package/file.go';

guessPackageNameFromFile(fileDir)
.then(([result]) => {
Expand All @@ -49,10 +49,10 @@ suite("GuessPackageNameFromFile Tests", () => {
.then(() => done(), done);
});

test("package name from test file", done => {
const expectedPackageName = "file";
const expectedPackageTestName = "file_test";
const fileDir = "file_test.go";
test('package name from test file', done => {
const expectedPackageName = 'file';
const expectedPackageTestName = 'file_test';
const fileDir = 'file_test.go';

guessPackageNameFromFile(fileDir)
.then(([packageNameResult, packageTestNameResult]) => {
Expand Down

0 comments on commit 056a756

Please sign in to comment.