mirror of
https://github.com/firstsun-dev/git-files-sync.git
synced 2026-07-22 17:20:30 +00:00
68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
import { vi } from 'vitest';
|
|
|
|
// Mock global browser environment if not in JSDOM
|
|
if (typeof document === 'undefined') {
|
|
(globalThis as unknown as { document: unknown }).document = {
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
};
|
|
}
|
|
if (typeof window === 'undefined') {
|
|
(globalThis as unknown as { window: unknown }).window = {
|
|
setInterval: vi.fn(),
|
|
clearInterval: vi.fn(),
|
|
};
|
|
}
|
|
|
|
// Mock Obsidian API components
|
|
export const Plugin = class {};
|
|
export const PluginSettingTab = class {
|
|
constructor() {}
|
|
};
|
|
export const Setting = class {
|
|
constructor() {}
|
|
setName() { return this; }
|
|
setDesc() { return this; }
|
|
addText() { return this; }
|
|
addToggle() { return this; }
|
|
addButton() { return this; }
|
|
};
|
|
export const Notice = class {
|
|
constructor() {}
|
|
};
|
|
export const Modal = class {
|
|
constructor() {}
|
|
open() {}
|
|
close() {}
|
|
};
|
|
export const MarkdownView = class {};
|
|
export const Editor = class {};
|
|
export const App = class {
|
|
workspace = {
|
|
getActiveViewOfType: vi.fn(),
|
|
on: vi.fn(),
|
|
};
|
|
vault = {
|
|
read: vi.fn(),
|
|
modify: vi.fn(),
|
|
getFileByPath: vi.fn(),
|
|
on: vi.fn(),
|
|
adapter: {
|
|
getBasePath: vi.fn().mockReturnValue('/mock/path'),
|
|
},
|
|
};
|
|
};
|
|
|
|
export const TFile = class {};
|
|
|
|
vi.mock('obsidian', () => ({
|
|
Plugin,
|
|
PluginSettingTab,
|
|
Setting,
|
|
Notice,
|
|
Modal,
|
|
MarkdownView,
|
|
Editor,
|
|
App,
|
|
TFile,
|
|
}));
|