Adds unit tests for core functionalities

Adds comprehensive unit tests to improve code coverage for core functionalities: constants, paper size mapping, modal settings, security utilities, temporary directory management, and variable mapping.

This ensures that basic functionalities work as expected and enhances the reliability of the plugin.

Additionally, this commit includes a mock Obsidian API to facilitate testing in a non-Obsidian environment.
This commit is contained in:
AlexKucera committed 2025-11-05 08:03:24 +01:00
1 parent 4a0376ec2b
commit 7ac9e1f489
10 files changed
+1494

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
// Mock Obsidian API for testing
import { vi } from 'vitest';
export class Notice {
constructor(message: string) {}
}
export class Plugin {
app: any;
manifest: any;
}
export class PluginSettingTab {
constructor(app: any, plugin: any) {}
}
export class Setting {
constructor(containerEl: HTMLElement) {}
setName(name: string): this { return this; }
setDesc(desc: string): this { return this; }
addText(cb: any): this { return this; }
addToggle(cb: any): this { return this; }
addDropdown(cb: any): this { return this; }
}
export class Modal {
constructor(app: any) {}
open(): void {}
close(): void {}
}
export class FuzzySuggestModal {
constructor(app: any) {}
}
export class TFile {
path = '';
basename = '';
extension = '';
}
export class TFolder {
path = '';
name = '';
}
export function normalizePath(path: string): string {
return path.replace(/\\/g, '/');
}
export const requestUrl = vi.fn();
// Type exports for compatibility
export interface App {
vault: {
adapter: {
exists: (path: string) => Promise<boolean>;
mkdir: (path: string) => Promise<void>;
remove: (path: string) => Promise<void>;
list: (path: string) => Promise<{ files: string[]; folders: string[] }>;
read: (path: string) => Promise<string>;
write: (path: string, data: string) => Promise<void>;
};
};
}