MCPcopy
hub / github.com/foambubble/foam / resetMockState

Function resetMockState

packages/foam-vscode/src/test/vscode-mock.ts:2340–2379  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2338
2339// Clean up state for tests
2340export function resetMockState(): void {
2341 // Clean up existing Foam instance
2342 TestFoam.dispose();
2343 mockState.activeTextEditor = undefined;
2344 mockState.visibleTextEditors = [];
2345 mockState.workspaceFolders = [];
2346 mockState.commands.clear();
2347 mockState.onWillRenameFilesListeners = [];
2348 mockState.onDidRenameFilesListeners = [];
2349 mockState.onWillDeleteFilesListeners = [];
2350 mockState.openDocuments.clear();
2351 mockState.configuration = new MockWorkspaceConfiguration();
2352
2353 // Create a default workspace folder for tests
2354 const defaultWorkspaceRoot = path.join(
2355 os.tmpdir(),
2356 'foam-mock-workspace-' + randomString(3)
2357 );
2358 fs.mkdirSync(defaultWorkspaceRoot, { recursive: true });
2359
2360 initializeWorkspace(defaultWorkspaceRoot);
2361
2362 // Register built-in VS Code commands
2363 commands.registerCommand('workbench.action.closeAllEditors', () => {
2364 mockState.activeTextEditor = undefined;
2365 mockState.visibleTextEditors = [];
2366 mockState.openDocuments.clear();
2367 return Promise.resolve();
2368 });
2369
2370 commands.registerCommand('vscode.open', async uri => {
2371 // Mock opening a file - just show it in editor
2372 return window.showTextDocument(uri);
2373 });
2374
2375 commands.registerCommand('setContext', (key: string, value: any) => {
2376 // Mock command for setting VS Code context
2377 return Promise.resolve();
2378 });
2379}
2380
2381// Initialize the mock state when the module is loaded
2382resetMockState();

Callers 1

vscode-mock.tsFile · 0.85

Calls 5

randomStringFunction · 0.90
initializeWorkspaceFunction · 0.85
disposeMethod · 0.65
clearMethod · 0.65
resolveMethod · 0.65

Tested by

no test coverage detected