Skip to content

Commit e5fc830

Browse files
committed
chore: add glob as devDependencies
Signed-off-by: Wei Wu <[email protected]>
1 parent bd9a2aa commit e5fc830

File tree

8 files changed

+179
-73
lines changed

8 files changed

+179
-73
lines changed

client/test/connection/itc/Coderunner.test.ts

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,7 @@ import sinon from "sinon";
33

44
import * as connection from "../../../src/connection";
55
import { runCode } from "../../../src/connection/itc/CodeRunner";
6-
import { Session } from "../../../src/connection/session";
7-
8-
export class MockSession extends Session {
9-
private _logFn;
10-
private _runMap: Record<string, string> | undefined;
11-
public sasSystemLine = "The Sas System";
12-
13-
public set onSessionLogFn(logFn) {
14-
this._logFn = logFn;
15-
}
16-
public set onExecutionLogFn(logFn) {
17-
this._logFn = logFn;
18-
}
19-
20-
public constructor(runMap?: Record<string, string>) {
21-
super();
22-
this._runMap = runMap;
23-
}
24-
25-
protected async establishConnection(): Promise<void> {
26-
return;
27-
}
28-
29-
public async run(codeString: string): Promise<connection.RunResult> {
30-
if (this._runMap) {
31-
const [, result] = Object.entries(this._runMap).find(([code]) =>
32-
codeString.includes(code),
33-
);
34-
if (result) {
35-
this._logFn(
36-
result.split("\n").map((line) => ({ line, type: "normal" })),
37-
);
38-
return;
39-
}
40-
}
41-
42-
this._logFn(
43-
codeString.split("\n").map((line) => ({ line, type: "normal" })),
44-
);
45-
return {};
46-
}
47-
48-
public close(): void | Promise<void> {}
49-
50-
public sessionId?(): string {
51-
return "";
52-
}
53-
}
6+
import { MockSession } from "../../utils";
547

558
describe("CodeRunner tests", () => {
569
let sessionStub;

client/test/connection/itc/ItcLibraryAdapter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "../../../src/components/LibraryNavigator/types";
88
import * as connection from "../../../src/connection";
99
import ItcLibraryAdapter from "../../../src/connection/itc/ItcLibraryAdapter";
10-
import { MockSession } from "./Coderunner.test";
10+
import { MockSession } from "../../utils";
1111

1212
const mockOutput = (now) => ({
1313
COLOUTPUT: `

client/test/index.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import glob from "glob";
1+
import { glob } from "glob";
22
import Mocha from "mocha";
33
import path from "path";
44

@@ -17,27 +17,26 @@ export function run(): Promise<void> {
1717
: "**/**.test.js";
1818

1919
return new Promise((resolve, reject) => {
20-
glob(pattern, { cwd: testsRoot }, (err, files) => {
21-
if (err) {
22-
return reject(err);
23-
}
20+
glob(pattern, { cwd: testsRoot, windowsPathsNoEscape: true }).then(
21+
(files) => {
22+
// Add files to the test suite
23+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
2424

25-
// Add files to the test suite
26-
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
27-
28-
try {
29-
// Run the mocha test
30-
mocha.run((failures) => {
31-
if (failures > 0) {
32-
reject(new Error(`${failures} tests failed.`));
33-
} else {
34-
resolve();
35-
}
36-
});
37-
} catch (err) {
38-
console.error(err);
39-
reject(err);
40-
}
41-
});
25+
try {
26+
// Run the mocha test
27+
mocha.run((failures) => {
28+
if (failures > 0) {
29+
reject(new Error(`${failures} tests failed.`));
30+
} else {
31+
resolve();
32+
}
33+
});
34+
} catch (err) {
35+
console.error(err);
36+
reject(err);
37+
}
38+
},
39+
reject,
40+
);
4241
});
4342
}

client/test/utils.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { assert } from "chai";
44
import { readFileSync } from "fs";
55
import * as path from "path";
66

7+
import type { RunResult } from "../src/connection";
8+
import { Session } from "../src/connection/session";
9+
710
export function getUri(name: string): vscode.Uri {
811
return vscode.Uri.file(path.resolve(__dirname, "../../testFixture", name));
912
}
@@ -43,3 +46,50 @@ export const assertThrowsAsync = async (fn, expectedMsg?: string) => {
4346
}
4447
assert.fail("function was expected to throw, but did not");
4548
};
49+
50+
export class MockSession extends Session {
51+
private _logFn;
52+
private _runMap: Record<string, string> | undefined;
53+
public sasSystemLine = "The Sas System";
54+
55+
public set onSessionLogFn(logFn) {
56+
this._logFn = logFn;
57+
}
58+
public set onExecutionLogFn(logFn) {
59+
this._logFn = logFn;
60+
}
61+
62+
public constructor(runMap?: Record<string, string>) {
63+
super();
64+
this._runMap = runMap;
65+
}
66+
67+
protected async establishConnection(): Promise<void> {
68+
return;
69+
}
70+
71+
public async run(codeString: string): Promise<RunResult> {
72+
if (this._runMap) {
73+
const [, result] = Object.entries(this._runMap).find(([code]) =>
74+
codeString.includes(code),
75+
);
76+
if (result) {
77+
this._logFn(
78+
result.split("\n").map((line) => ({ line, type: "normal" })),
79+
);
80+
return;
81+
}
82+
}
83+
84+
this._logFn(
85+
codeString.split("\n").map((line) => ({ line, type: "normal" })),
86+
);
87+
return {};
88+
}
89+
90+
public close(): void | Promise<void> {}
91+
92+
public sessionId?(): string {
93+
return "";
94+
}
95+
}

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,7 @@
11191119
"eslint": "^9.12.0",
11201120
"eslint-plugin-react": "^7.37.1",
11211121
"eslint-plugin-react-hooks": "^5.0.0",
1122+
"glob": "^11.0.0",
11221123
"mocha": "^10.7.3",
11231124
"nock": "^13.5.4",
11241125
"papaparse": "^5.4.1",

tools/check-copyright.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFileSync, writeFileSync } from "fs";
2-
import glob from "glob";
2+
import { glob } from "glob";
33

44
// These files will not be checked for copyright information
55
const filesToIgnore = [

tools/locale.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFileSync, writeFileSync } from "fs";
2-
import glob from "glob";
2+
import { glob } from "glob";
33
import csv from "papaparse";
44
import { dirname, isAbsolute, join } from "path";
55
import { fileURLToPath } from "url";

0 commit comments

Comments
 (0)