Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 6x 155x 20x 6x 6x 6x 6x 6x 78x 20x 45x 45x 16x 6x 20x 20x 16x 16x 1x 6x 30x 6x 6x 16x 8x 8x 15x 5x 26x 11x 11x 15x 15x 38x 38x 11x 11x 6x 50x 6x 30x 16x | import { vi } from 'vitest';
export const Uri = {
file: (path: string) => ({
fsPath: path,
toString: () => `file://${path}`,
scheme: 'file',
path,
}),
parse: (str: string) => ({
fsPath: str.replace('file://', ''),
toString: () => str,
scheme: 'file',
path: str.replace('file://', ''),
}),
};
export enum ViewColumn {
Active = -1,
Beside = -2,
One = 1,
Two = 2,
}
const createMockDisposable = () => ({ dispose: vi.fn() });
const createMockWebview = () => ({
html: '',
cspSource: 'https://mock-csp-source',
options: undefined as any,
asWebviewUri: vi.fn((uri: any) => ({
...uri,
toString: () => `https://webview-uri${uri.path || uri.fsPath}`,
})),
postMessage: vi.fn().mockResolvedValue(true),
onDidReceiveMessage: vi.fn(() => createMockDisposable()),
});
const createMockPanel = () => {
const webview = createMockWebview();
let disposeCallback: (() => void) | undefined;
return {
webview,
reveal: vi.fn(),
dispose: vi.fn(() => disposeCallback?.()),
onDidDispose: vi.fn((cb: () => void) => {
disposeCallback = cb;
return createMockDisposable();
}),
onDidChangeViewState: vi.fn(() => createMockDisposable()),
iconPath: undefined as any,
title: '',
viewType: 'vibeDocuments.preview',
active: true,
visible: true,
viewColumn: ViewColumn.Active,
_disposeCallback: () => disposeCallback?.(),
};
};
export const window = {
createWebviewPanel: vi.fn((_viewType: string, title: string) => {
const panel = createMockPanel();
panel.title = title;
return panel;
}),
registerCustomEditorProvider: vi.fn((_viewType: string, _provider: any, _options?: any) => createMockDisposable()),
activeTextEditor: undefined as any,
showErrorMessage: vi.fn(),
showInformationMessage: vi.fn(),
};
const createMockFileSystemWatcher = () => ({
onDidChange: vi.fn(() => createMockDisposable()),
onDidCreate: vi.fn(() => createMockDisposable()),
onDidDelete: vi.fn(() => createMockDisposable()),
dispose: vi.fn(),
});
export const workspace = {
openTextDocument: vi.fn().mockResolvedValue({
getText: () => '# Test Markdown\n\nHello world',
uri: Uri.file('/test/file.md'),
fileName: '/test/file.md',
isDirty: false,
save: vi.fn().mockResolvedValue(true),
}),
createFileSystemWatcher: vi.fn(() => createMockFileSystemWatcher()),
onDidChangeTextDocument: vi.fn(() => createMockDisposable()),
onDidSaveTextDocument: vi.fn(() => createMockDisposable()),
workspaceFolders: [{ uri: Uri.file('/test/workspace') }],
applyEdit: vi.fn().mockResolvedValue(true),
};
export class WorkspaceEdit {
private _edits: Array<{ type: 'replace' | 'insert' | 'delete'; uri: any; range?: any; position?: any; newText?: string }> = [];
replace(uri: any, range: any, newText: string) {
this._edits.push({ type: 'replace', uri, range, newText });
}
insert(uri: any, position: any, newText: string) {
this._edits.push({ type: 'insert', uri, position, newText });
}
delete(uri: any, range: any) {
this._edits.push({ type: 'delete', uri, range });
}
getEdits() {
return this._edits;
}
}
export class Range {
public readonly start: { line: number; character: number };
public readonly end: { line: number; character: number };
constructor(startLine: number | any, startChar?: number | any, endLine?: number, endChar?: number) {
if (typeof startLine === 'number' && typeof startChar === 'number') {
this.start = { line: startLine, character: startChar };
this.end = { line: endLine ?? startLine, character: endChar ?? startChar };
} else {
this.start = startLine;
this.end = startChar;
}
}
}
export class Position {
constructor(
public readonly line: number,
public readonly character: number
) {}
}
export class CodeLens {
public readonly range: Range;
public readonly command?: any;
constructor(range: Range, command?: any) {
this.range = range;
this.command = command;
}
}
export const commands = {
registerCommand: vi.fn((command: string, callback: (...args: any[]) => any) => {
return { command, callback, dispose: vi.fn() };
}),
executeCommand: vi.fn().mockResolvedValue(undefined),
};
export const languages = {
registerCodeLensProvider: vi.fn((_selector: any, _provider: any) => {
return { dispose: vi.fn() };
}),
};
export class ThemeIcon {
constructor(public readonly id: string) {}
}
export class RelativePattern {
constructor(
public readonly base: any,
public readonly pattern: string
) {}
}
export { createMockPanel, createMockWebview };
|