|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT license. |
| 3 | + |
| 4 | +const path = require("path"); |
| 5 | + |
| 6 | +// Class |
| 7 | +const Uri = { |
| 8 | + fsPath: "defaultPath", |
| 9 | + file: jest.fn() |
| 10 | +}; |
| 11 | + |
| 12 | +const Diagnostic = jest.fn((range, message, severity) => { |
| 13 | + return { |
| 14 | + range, |
| 15 | + message, |
| 16 | + severity |
| 17 | + }; |
| 18 | +}); |
| 19 | + |
| 20 | +const Range = jest.fn(); |
| 21 | + |
| 22 | +// Interface |
| 23 | +const OutputChannel = { |
| 24 | + appendLine: jest.fn(), |
| 25 | + show: jest.fn(), |
| 26 | + dispose: jest.fn() |
| 27 | +}; |
| 28 | + |
| 29 | +const ExtensionContext = { |
| 30 | + asAbsolutePath: jest.fn(p => { |
| 31 | + const rootPath = path.resolve(__dirname, ".."); |
| 32 | + return path.join(rootPath, p); |
| 33 | + }) |
| 34 | +}; |
| 35 | + |
| 36 | +const WorkspaceFolder = { |
| 37 | + uri: Uri |
| 38 | +}; |
| 39 | + |
| 40 | +const TextDocument = { |
| 41 | + uri: Uri, |
| 42 | + getText: jest.fn(), |
| 43 | + positionAt: jest.fn() |
| 44 | +}; |
| 45 | + |
| 46 | +const DiagnosticCollection = { |
| 47 | + set: jest.fn(), |
| 48 | + delete: jest.fn() |
| 49 | +}; |
| 50 | + |
| 51 | +const QuickPickOptions = {}; |
| 52 | + |
| 53 | +const QuickPickItem = {}; |
| 54 | + |
| 55 | +const OpenDialogOptions = {}; |
| 56 | + |
| 57 | +const InputBoxOptions = {}; |
| 58 | + |
| 59 | +// Enum |
| 60 | +const ConfigurationTarget = { |
| 61 | + Global: 1, |
| 62 | + workspace: 2, |
| 63 | + WorkspaceFolder: 3 |
| 64 | +}; |
| 65 | + |
| 66 | +const DiagnosticSeverity = { |
| 67 | + Error: 0, |
| 68 | + Warning: 1, |
| 69 | + Information: 2, |
| 70 | + Hint: 3 |
| 71 | +}; |
| 72 | + |
| 73 | +// Namespace |
| 74 | +const window = { |
| 75 | + createOutputChannel: jest.fn(() => OutputChannel), |
| 76 | + showQuickPick: jest.fn(items => items[0]), |
| 77 | + showOpenDialog: jest.fn(), |
| 78 | + showInputBox: jest.fn(), |
| 79 | + showTextDocument: jest.fn(), |
| 80 | + showInformationMessage: jest.fn(), |
| 81 | + showWarningMessage: jest.fn(), |
| 82 | + showErrorMessage: jest.fn() |
| 83 | +}; |
| 84 | + |
| 85 | +const commands = { |
| 86 | + executeCommand: jest.fn() |
| 87 | +}; |
| 88 | + |
| 89 | +const workspace = { |
| 90 | + workspaceFolders: undefined |
| 91 | +}; |
| 92 | + |
| 93 | +const vscode = { |
| 94 | + // Class |
| 95 | + Uri, |
| 96 | + Diagnostic, |
| 97 | + Range, |
| 98 | + |
| 99 | + // Interface |
| 100 | + OutputChannel, |
| 101 | + ExtensionContext, |
| 102 | + WorkspaceFolder, |
| 103 | + QuickPickOptions, |
| 104 | + QuickPickItem, |
| 105 | + OpenDialogOptions, |
| 106 | + InputBoxOptions, |
| 107 | + TextDocument, |
| 108 | + DiagnosticCollection, |
| 109 | + |
| 110 | + // Enum |
| 111 | + ConfigurationTarget, |
| 112 | + DiagnosticSeverity, |
| 113 | + |
| 114 | + // Namespace |
| 115 | + window, |
| 116 | + commands, |
| 117 | + workspace |
| 118 | +}; |
| 119 | + |
| 120 | +module.exports = vscode; |
0 commit comments