MCPcopy
hub / github.com/callumalpass/tasknotes / Workspace

Class Workspace

tests/__mocks__/obsidian.ts:429–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427
428// Workspace mock class
429export class Workspace {
430 private emitter = new EventEmitter();
431 private activeView: any = null;
432 private views = new Map<string, any>();
433
434 getActiveView(): any {
435 return this.activeView;
436 }
437
438 setActiveView(view: any): void {
439 this.activeView = view;
440 this.emitter.emit('active-leaf-change');
441 }
442
443 getViewsOfType(type: string): any[] {
444 return Array.from(this.views.values()).filter(view => view.getViewType() === type);
445 }
446
447 detachLeavesOfType(type: string): void {
448 // Mock implementation
449 }
450
451 getLeavesOfType = jest.fn((type: string): any[] => {
452 return this.getViewsOfType(type);
453 });
454
455 getLeaf(newLeaf: boolean = true): any {
456 return {
457 open: jest.fn().mockResolvedValue(undefined),
458 openFile: jest.fn().mockResolvedValue(undefined)
459 };
460 }
461
462 // Event management
463 on(event: string, callback: (...args: any[]) => void): void {
464 this.emitter.on(event, callback);
465 }
466
467 off(event: string, callback: (...args: any[]) => void): void {
468 this.emitter.off(event, callback);
469 }
470
471 trigger(event: string, ...args: any[]): void {
472 this.emitter.emit(event, ...args);
473 }
474}
475
476// App mock class
477export class App {

Callers

nothing calls this directly

Calls 1

getViewsOfTypeMethod · 0.95

Tested by

no test coverage detected