Skip to content

Commit b238b6e

Browse files
committed
fix: use respective workspace uri on different platforms (#111)
* fix: use respective workspace uri on different platforms * chore: run unit test in ci * ui: update description of cnblogsClientForVSCode.{windows|macos}.chromiumPath * chore: remove resolveJsonModule: true from tsconfig.json * chore: use mjs for jest.config
1 parent 63b5c27 commit b238b6e

23 files changed

+7457
-2776
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"parserOptions": {
77
"ecmaVersion": 6,
88
"sourceType": "module",
9-
"project": ["./tsconfig.json", "./ui/tsconfig.json"]
9+
"project": ["./tsconfig.json", "./ui/tsconfig.json", "./test/tsconfig.json"]
1010
},
1111
"rules": {},
12-
"ignorePatterns": ["out", "dist", "src/test/**", "**/*.d.ts"],
12+
"ignorePatterns": ["out", "dist", "src/test/**", "**/*.d.ts", "__mocks__/vscode.ts"],
1313
"overrides": [
1414
{
1515
"files": ["*.config.js"],

.github/workflows/build-check.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222
cache: 'npm'
23-
- run: npm ci
24-
- run: npm run lint
25-
- run: npm run vscode:prepublish
23+
- name: 'Install Dependencies'
24+
run: npm ci
25+
- name: 'Lint'
26+
run: npm run lint
27+
- name: 'Unit Test'
28+
run: npm run test:unit
29+
- name: 'Build'
30+
run: npm run vscode:prepublish

.vscode/launch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"],
1313
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
1414
"preLaunchTask": "${defaultBuildTask}",
1515
"env": {
@@ -23,7 +23,8 @@
2323
"request": "launch",
2424
"args": [
2525
"--extensionDevelopmentPath=${workspaceFolder}",
26-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
26+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
27+
"--disable-extensions"
2728
],
2829
"outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"],
2930
"preLaunchTask": "tasks: watch-tests"

.vscode/settings.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@
1111
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1212
"typescript.tsc.autoDetect": "off",
1313
"editor.formatOnSave": true,
14-
"cSpell.words": ["ASPNETCORE", "fluentui", "iconfont", "ings", "nbsp", "randomstring", "singleline", "tailwindcss"],
14+
"cSpell.words": [
15+
"ASPNETCORE",
16+
"fluentui",
17+
"iconfont",
18+
"ings",
19+
"nbsp",
20+
"randomstring",
21+
"singleline",
22+
"tailwindcss",
23+
"untildify"
24+
],
1525
"json.format.enable": false,
1626
"eslint.alwaysShowStatus": true,
1727
"eslint.lintTask.enable": true,
@@ -20,5 +30,6 @@
2030
"eslint.format.enable": true,
2131
"editor.codeActionsOnSave": {
2232
"source.fixAll": true
23-
}
33+
},
34+
"jest.jestCommandLine": "npm run test:unit -- "
2435
}

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
{
4646
"type": "npm",
47-
"script": "watch-tests",
47+
"script": "test:integration:watch",
4848
"problemMatcher": "$tsc-watch",
4949
"isBackground": true,
5050
"presentation": {
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"label": "tasks: watch-tests",
58-
"dependsOn": ["npm: watch", "npm: watch-tests"],
58+
"dependsOn": ["watch", "npm: test:integration:watch"],
5959
"problemMatcher": []
6060
}
6161
]

__mocks__/vscode.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
const languages = {
2+
createDiagnosticCollection: jest.fn(),
3+
registerCodeLensProvider: jest.fn(),
4+
};
5+
6+
const StatusBarAlignment = { Left: 1, Right: 2 };
7+
8+
const window = {
9+
createStatusBarItem: jest.fn(() => ({
10+
show: jest.fn(),
11+
tooltip: jest.fn(),
12+
})),
13+
showErrorMessage: jest.fn(),
14+
showWarningMessage: jest.fn(),
15+
createTextEditorDecorationType: jest.fn(),
16+
createOutputChannel: jest.fn(),
17+
showWorkspaceFolderPick: jest.fn(),
18+
onDidChangeActiveTextEditor: jest.fn(),
19+
showInformationMessage: jest.fn(),
20+
createWebviewPanel: jest.fn(),
21+
};
22+
23+
const workspace = {
24+
getConfiguration: jest.fn().mockReturnValue({
25+
get: jest.fn(),
26+
update: jest.fn(),
27+
has: jest.fn(),
28+
inspect: jest.fn(),
29+
}),
30+
workspaceFolders: [],
31+
getWorkspaceFolder: jest.fn(),
32+
33+
onDidChangeConfiguration: jest.fn(),
34+
onDidChangeTextDocument: jest.fn(),
35+
onDidChangeWorkspaceFolders: jest.fn(),
36+
onDidCreateFiles: jest.fn(),
37+
onDidDeleteFiles: jest.fn(),
38+
onDidRenameFiles: jest.fn(),
39+
onDidSaveTextDocument: jest.fn(),
40+
onWillSaveTextDocument: jest.fn(),
41+
};
42+
43+
const OverviewRulerLane = {
44+
Left: null,
45+
};
46+
47+
const Uri = {
48+
// @ts-ignore
49+
file: f => f,
50+
parse: jest.fn(),
51+
joinPath: jest.fn(),
52+
};
53+
const Range = jest.fn();
54+
const Location = jest.fn();
55+
const Position = jest.fn();
56+
const Diagnostic = jest.fn();
57+
const ThemeIcon = jest.fn();
58+
const DiagnosticSeverity = { Error: 0, Warning: 1, Information: 2, Hint: 3 };
59+
const ConfigurationTarget = { Global: 1, Workspace: 2, WorkspaceFolder: 3 };
60+
61+
const debug = {
62+
onDidTerminateDebugSession: jest.fn(),
63+
startDebugging: jest.fn(),
64+
registerDebugConfigurationProvider: jest.fn(),
65+
};
66+
67+
const commands = {
68+
executeCommand: jest.fn(),
69+
registerCommand: jest.fn(),
70+
registerTextEditorCommand: jest.fn(),
71+
};
72+
73+
// eslint-disable-next-line @typescript-eslint/no-empty-function
74+
const CodeLens = function CodeLens() {};
75+
76+
const QuickInputButtons = {
77+
Back: {},
78+
};
79+
80+
const tests = {
81+
createTestController: jest.fn(),
82+
};
83+
84+
const TestRunProfileKind = {
85+
Run: 1,
86+
Debug: 2,
87+
Coverage: 3,
88+
};
89+
const ViewColumn = {
90+
One: 1,
91+
Tow: 2,
92+
};
93+
94+
const TestMessage = jest.fn();
95+
const TestRunRequest = jest.fn();
96+
const ThemeColor = jest.fn();
97+
98+
const EventEmitter = jest.fn().mockImplementation(() => {
99+
return {
100+
fire: jest.fn(),
101+
};
102+
});
103+
104+
const QuickPickItemKind = {
105+
Separator: -1,
106+
Default: 0,
107+
};
108+
109+
export = {
110+
ThemeColor,
111+
CodeLens,
112+
languages,
113+
StatusBarAlignment,
114+
window,
115+
workspace,
116+
OverviewRulerLane,
117+
Uri,
118+
Range,
119+
Location,
120+
Position,
121+
Diagnostic,
122+
ThemeIcon,
123+
DiagnosticSeverity,
124+
ConfigurationTarget,
125+
debug,
126+
commands,
127+
QuickInputButtons,
128+
tests,
129+
TestRunProfileKind,
130+
EventEmitter,
131+
TestMessage,
132+
TestRunRequest,
133+
ViewColumn,
134+
QuickPickItemKind,
135+
};

0 commit comments

Comments
 (0)