From d461e231f0ec46cc48c353cf5062a9aec574ef08 Mon Sep 17 00:00:00 2001 From: duanfuxiang Date: Tue, 7 Jan 2025 14:47:40 +0800 Subject: [PATCH] fix unit test --- src/types/settings.ts | 2 +- src/utils/obsidian.test.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/types/settings.ts b/src/types/settings.ts index ab0acd5..d8113d3 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -233,7 +233,7 @@ export function parseInfioSettings(data: unknown): InfioSettings { const migratedData = migrateSettings(data as Record) return InfioSettingsSchema.parse(migratedData) } catch (error) { - console.warn('Invalid settings provided, using defaults:', error) + // console.warn('Invalid settings provided, using defaults:', error) return InfioSettingsSchema.parse({ ...DEFAULT_AUTOCOMPLETE_SETTINGS }) } } diff --git a/src/utils/obsidian.test.ts b/src/utils/obsidian.test.ts index 7422e26..d10c910 100644 --- a/src/utils/obsidian.test.ts +++ b/src/utils/obsidian.test.ts @@ -12,6 +12,15 @@ describe('calculateFileDistance', () => { } } + // Mock TFolder class + class MockTFolder extends TFolder { + path: string + constructor(path: string) { + super() + this.path = path + } + } + it('should calculate the correct distance between files in the same folder', () => { const file1 = new MockTFile('folder/file1.md') const file2 = new MockTFile('folder/file2.md') @@ -53,7 +62,7 @@ describe('calculateFileDistance', () => { it('should calculate the correct distance between a folder and a file', () => { const file = new MockTFile('folder1/folder2/file1.md') - const folder = new MockTFile('folder1/folder2') + const folder = new MockTFolder('folder1/folder2') if (!(folder instanceof TFolder)) { throw new Error('Expected folder to be a TFolder instance') }