chore(metaagent): рабочее пространство агента и заготовка тестов
CI / Lint & Test (push) Canceled after 0s
CI / Lint & Test (push) Canceled after 0s
- .agent/: контекст, запросы, роадмап, задачи, шаблоны и протоколы - заготовка тестовой инфраструктуры: vitest, eslint, prettier, ci-workflow
This commit is contained in:
1 parent
7443ec059f
commit
3e1d9776c3
66 files changed
+7150
-696
No files matched your search
@@ -0,0 +1,279 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
// Mock the Obsidian API surface used by AttachmentCleanPasteModule.
|
||||
// vi.mock is hoisted above imports, so the module-under-test resolves to this
|
||||
// stub instead of the alias target in __mocks__/obsidian.ts (which only
|
||||
// exports `Plugin`).
|
||||
vi.mock('obsidian', () => ({
|
||||
App: class {},
|
||||
Editor: class {},
|
||||
MarkdownFileInfo: class {},
|
||||
MarkdownView: class {},
|
||||
Notice: class {
|
||||
constructor(public message: string) {}
|
||||
},
|
||||
Setting: class {
|
||||
constructor(_el: HTMLElement) {}
|
||||
setName(_n: string): this {
|
||||
return this;
|
||||
}
|
||||
setDesc(_d: string): this {
|
||||
return this;
|
||||
}
|
||||
addTextArea(_cb: (textarea: unknown) => void): this {
|
||||
return this;
|
||||
}
|
||||
},
|
||||
// Minimal normalizePath: collapses backslashes, collapses duplicate slashes,
|
||||
// strips leading/trailing slash. Sufficient for the inputs in these tests.
|
||||
normalizePath: (p: string): string =>
|
||||
p.replace(/\\/g, '/').replace(/\/+/g, '/').replace(/^\/|\/$/g, ''),
|
||||
Plugin: class {},
|
||||
}));
|
||||
|
||||
import { AttachmentCleanPasteModule } from '../../src/modules/attachment-clean-paste';
|
||||
|
||||
// Build a minimal File-like object compatible with the module's usage
|
||||
// (only `name` and `arrayBuffer()` are read).
|
||||
function createFile(name: string, content: string = 'data'): File {
|
||||
return {
|
||||
name,
|
||||
arrayBuffer: async () =>
|
||||
new TextEncoder().encode(content).buffer as ArrayBuffer,
|
||||
} as unknown as File;
|
||||
}
|
||||
|
||||
describe('AttachmentCleanPasteModule', () => {
|
||||
let module: AttachmentCleanPasteModule;
|
||||
let mockPlugin: Record<string, unknown>;
|
||||
let mockWorkspace: {
|
||||
on: ReturnType<typeof vi.fn>;
|
||||
offref: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
let mockVault: {
|
||||
getConfig: ReturnType<typeof vi.fn>;
|
||||
adapter: { exists: ReturnType<typeof vi.fn> };
|
||||
createFolder: ReturnType<typeof vi.fn>;
|
||||
getAvailablePath: ReturnType<typeof vi.fn>;
|
||||
createBinary: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
let pasteHandler:
|
||||
| ((evt: ClipboardEvent, editor: unknown, info: unknown) => Promise<void>)
|
||||
| null;
|
||||
let dropHandler:
|
||||
| ((evt: DragEvent, editor: unknown, info: unknown) => Promise<void>)
|
||||
| null;
|
||||
let settings: { extensions: string };
|
||||
|
||||
beforeEach(() => {
|
||||
pasteHandler = null;
|
||||
dropHandler = null;
|
||||
|
||||
mockWorkspace = {
|
||||
on: vi.fn((event: string, handler: unknown) => {
|
||||
if (event === 'editor-paste') {
|
||||
pasteHandler = handler as typeof pasteHandler;
|
||||
} else if (event === 'editor-drop') {
|
||||
dropHandler = handler as typeof dropHandler;
|
||||
}
|
||||
return { event, handler };
|
||||
}),
|
||||
offref: vi.fn(),
|
||||
};
|
||||
|
||||
const mockAdapter = {
|
||||
exists: vi.fn(async () => true),
|
||||
};
|
||||
|
||||
mockVault = {
|
||||
getConfig: vi.fn((key: string) =>
|
||||
key === 'attachmentFolderPath' ? 'attachments' : '',
|
||||
),
|
||||
adapter: mockAdapter,
|
||||
createFolder: vi.fn(async () => undefined),
|
||||
// Mirrors the real Obsidian contract: returns "<basePath>.<ext>".
|
||||
getAvailablePath: vi.fn(
|
||||
async (basePath: string, ext: string) => `${basePath}.${ext}`,
|
||||
),
|
||||
createBinary: vi.fn(async () => undefined),
|
||||
};
|
||||
|
||||
mockPlugin = {
|
||||
app: {
|
||||
workspace: mockWorkspace,
|
||||
vault: mockVault,
|
||||
},
|
||||
};
|
||||
|
||||
settings = { extensions: 'png, jpg' };
|
||||
|
||||
module = new AttachmentCleanPasteModule();
|
||||
module.onload(
|
||||
mockPlugin as unknown as Parameters<
|
||||
AttachmentCleanPasteModule['onload']
|
||||
>[0],
|
||||
settings,
|
||||
);
|
||||
});
|
||||
|
||||
describe('shouldProcess', () => {
|
||||
// Helper: mustProcess is a private method; reach it via a typed cast.
|
||||
const callShouldProcess = (
|
||||
filename: string,
|
||||
cfg: { extensions: string } = settings,
|
||||
): boolean =>
|
||||
(
|
||||
module as unknown as {
|
||||
shouldProcess: (
|
||||
f: string,
|
||||
s: { extensions: string },
|
||||
) => boolean;
|
||||
}
|
||||
).shouldProcess(filename, cfg);
|
||||
|
||||
it('возвращает true для расширений из настроек (png, jpg)', () => {
|
||||
expect(callShouldProcess('image.png')).toBe(true);
|
||||
expect(callShouldProcess('photo.jpg')).toBe(true);
|
||||
});
|
||||
|
||||
it('возвращает false для расширений НЕ из настроек (exe, zip)', () => {
|
||||
expect(callShouldProcess('malware.exe')).toBe(false);
|
||||
expect(callShouldProcess('archive.zip')).toBe(false);
|
||||
});
|
||||
|
||||
it('возвращает false для файлов без расширения', () => {
|
||||
expect(callShouldProcess('README')).toBe(false);
|
||||
expect(callShouldProcess('Makefile')).toBe(false);
|
||||
});
|
||||
|
||||
it('корректно обрабатывает запятые и пробелы в extensions ("png, jpg" → png и jpg)', () => {
|
||||
const cfg = { extensions: ' png , jpg ' };
|
||||
expect(callShouldProcess('image.png', cfg)).toBe(true);
|
||||
expect(callShouldProcess('photo.jpg', cfg)).toBe(true);
|
||||
// Negative case: gif is not in the list.
|
||||
expect(callShouldProcess('anim.gif', cfg)).toBe(false);
|
||||
});
|
||||
|
||||
it('case-insensitive: JPG матчится как jpg', () => {
|
||||
expect(callShouldProcess('IMAGE.JPG')).toBe(true);
|
||||
expect(callShouldProcess('photo.PNG')).toBe(true);
|
||||
expect(callShouldProcess('Mixed.JpG')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('paste handler (createPasteHandler)', () => {
|
||||
it('вызывает preventDefault для файлов с подходящими расширениями', async () => {
|
||||
const editor = { replaceSelection: vi.fn() };
|
||||
const file = createFile('image.png');
|
||||
|
||||
const preventDefault = vi.fn();
|
||||
const stopPropagation = vi.fn();
|
||||
const evt = {
|
||||
clipboardData: { files: [file] },
|
||||
preventDefault,
|
||||
stopPropagation,
|
||||
} as unknown as ClipboardEvent;
|
||||
|
||||
expect(pasteHandler).not.toBeNull();
|
||||
await pasteHandler!(evt, editor, {});
|
||||
|
||||
// Matching extension → processAll took over the event.
|
||||
expect(preventDefault).toHaveBeenCalledTimes(1);
|
||||
expect(stopPropagation).toHaveBeenCalledTimes(1);
|
||||
// The link was inserted into the editor.
|
||||
expect(editor.replaceSelection).toHaveBeenCalledTimes(1);
|
||||
expect(editor.replaceSelection).toHaveBeenCalledWith(
|
||||
'[[attachments/image.png|image]]',
|
||||
);
|
||||
});
|
||||
|
||||
it('НЕ вызывает preventDefault, если ни один файл не подходит по расширению', async () => {
|
||||
const editor = { replaceSelection: vi.fn() };
|
||||
const file = createFile('malware.exe');
|
||||
|
||||
const preventDefault = vi.fn();
|
||||
const stopPropagation = vi.fn();
|
||||
const evt = {
|
||||
clipboardData: { files: [file] },
|
||||
preventDefault,
|
||||
stopPropagation,
|
||||
} as unknown as ClipboardEvent;
|
||||
|
||||
expect(pasteHandler).not.toBeNull();
|
||||
await pasteHandler!(evt, editor, {});
|
||||
|
||||
expect(preventDefault).not.toHaveBeenCalled();
|
||||
expect(stopPropagation).not.toHaveBeenCalled();
|
||||
expect(editor.replaceSelection).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('processFile', () => {
|
||||
it('формирует ссылку в формате "[[path|name]]"', async () => {
|
||||
const file = createFile('image.png');
|
||||
|
||||
const result = await (
|
||||
module as unknown as {
|
||||
processFile: (
|
||||
f: File,
|
||||
s: { extensions: string },
|
||||
) => Promise<string | null>;
|
||||
}
|
||||
).processFile(file, settings);
|
||||
|
||||
expect(result).toBe('[[attachments/image.png|image]]');
|
||||
expect(mockVault.createBinary).toHaveBeenCalledTimes(1);
|
||||
// The binary payload was passed to the vault.
|
||||
const [, payload] = (
|
||||
mockVault.createBinary.mock.calls[0] as [string, ArrayBuffer]
|
||||
);
|
||||
expect(payload).toBeInstanceOf(ArrayBuffer);
|
||||
});
|
||||
|
||||
it('использует имя файла без расширения как alias', async () => {
|
||||
const file = createFile('my-screenshot.png');
|
||||
|
||||
const result = await (
|
||||
module as unknown as {
|
||||
processFile: (
|
||||
f: File,
|
||||
s: { extensions: string },
|
||||
) => Promise<string | null>;
|
||||
}
|
||||
).processFile(file, settings);
|
||||
|
||||
expect(result).toBe('[[attachments/my-screenshot.png|my-screenshot]]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('defaultSettings', () => {
|
||||
it('содержит разумный список расширений по умолчанию', () => {
|
||||
expect(module.defaultSettings).toEqual({
|
||||
extensions: 'png, jpg, jpeg, gif, svg, webp, bmp, pdf',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('onload lifecycle', () => {
|
||||
it('регистрирует оба обработчика (editor-paste и editor-drop) в workspace', () => {
|
||||
expect(mockWorkspace.on).toHaveBeenCalledWith(
|
||||
'editor-paste',
|
||||
expect.any(Function),
|
||||
);
|
||||
expect(mockWorkspace.on).toHaveBeenCalledWith(
|
||||
'editor-drop',
|
||||
expect.any(Function),
|
||||
);
|
||||
});
|
||||
|
||||
it('onunload отключает оба зарегистрированных обработчика', () => {
|
||||
module.onunload(
|
||||
mockPlugin as unknown as Parameters<
|
||||
AttachmentCleanPasteModule['onunload']
|
||||
>[0],
|
||||
);
|
||||
|
||||
expect(mockWorkspace.offref).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { Plugin } from 'obsidian';
|
||||
import { BaseModule } from '../../src/modules/base-module';
|
||||
|
||||
// TestModule: minimal concrete subclass to exercise BaseModule behavior.
|
||||
// Exposes a `cleanupCount` accessor so tests can verify private state.
|
||||
class TestModule extends BaseModule {
|
||||
id = 'test-module';
|
||||
name = 'Test Module';
|
||||
description = 'Used in BaseModule unit tests';
|
||||
|
||||
// Test-only inspector: exposes the size of the private cleanupFns array.
|
||||
get cleanupCount(): number {
|
||||
return (this as unknown as { cleanupFns: (() => void)[] }).cleanupFns.length;
|
||||
}
|
||||
|
||||
// Surface protected registerCleanup for direct test access.
|
||||
public callRegisterCleanup(fn: () => void): void {
|
||||
this.registerCleanup(fn);
|
||||
}
|
||||
|
||||
onload(_plugin: Plugin, _moduleSettings: Record<string, unknown>): void {
|
||||
// no-op: BaseModule's onload contract is exercised elsewhere.
|
||||
}
|
||||
}
|
||||
|
||||
function makePlugin(): Plugin {
|
||||
// Hand-rolled minimal mock to avoid pulling the real Obsidian runtime.
|
||||
return {} as Plugin;
|
||||
}
|
||||
|
||||
describe('BaseModule', () => {
|
||||
it('registerCleanup добавляет функцию в очередь (cleanupFns)', () => {
|
||||
const module = new TestModule();
|
||||
const cleanup = vi.fn();
|
||||
|
||||
module.callRegisterCleanup(cleanup);
|
||||
|
||||
expect(module.cleanupCount).toBe(1);
|
||||
expect(cleanup).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('onunload вызывает все зарегистрированные cleanup-функции', () => {
|
||||
const module = new TestModule();
|
||||
const cleanupA = vi.fn();
|
||||
const cleanupB = vi.fn();
|
||||
|
||||
module.callRegisterCleanup(cleanupA);
|
||||
module.callRegisterCleanup(cleanupB);
|
||||
|
||||
module.onunload(makePlugin());
|
||||
|
||||
expect(cleanupA).toHaveBeenCalledTimes(1);
|
||||
expect(cleanupB).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('onunload очищает очередь после выполнения (cleanupFns === [])', () => {
|
||||
const module = new TestModule();
|
||||
module.callRegisterCleanup(vi.fn());
|
||||
module.callRegisterCleanup(vi.fn());
|
||||
module.callRegisterCleanup(vi.fn());
|
||||
|
||||
expect(module.cleanupCount).toBe(3);
|
||||
|
||||
module.onunload(makePlugin());
|
||||
|
||||
expect(module.cleanupCount).toBe(0);
|
||||
});
|
||||
|
||||
it('defaultSettings возвращает пустой объект {}', () => {
|
||||
const module = new TestModule();
|
||||
|
||||
expect(module.defaultSettings).toEqual({});
|
||||
// Belt-and-suspenders: identity check for a fresh object each call.
|
||||
expect(module.defaultSettings).not.toBe(module.defaultSettings);
|
||||
});
|
||||
|
||||
it('несколько cleanup-функций: registerCleanup можно вызвать несколько раз и все выполнятся при onunload', () => {
|
||||
const module = new TestModule();
|
||||
const fns = [vi.fn(), vi.fn(), vi.fn(), vi.fn()];
|
||||
|
||||
for (const fn of fns) {
|
||||
module.callRegisterCleanup(fn);
|
||||
}
|
||||
|
||||
expect(module.cleanupCount).toBe(fns.length);
|
||||
|
||||
module.onunload(makePlugin());
|
||||
|
||||
for (const fn of fns) {
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
}
|
||||
expect(module.cleanupCount).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,236 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { TFile, Vault } from 'obsidian';
|
||||
import { PreserveLinkAliasesModule } from '../../src/modules/preserve-link-aliases';
|
||||
|
||||
interface PreserveLinkAliasesSettings {
|
||||
processEmbeds: boolean;
|
||||
processCanvas: boolean;
|
||||
}
|
||||
|
||||
// TestablePreserveLinkAliasesModule: surface the private members so tests
|
||||
// can invoke processContent / getFilesToProcess / handleRename directly.
|
||||
class TestablePreserveLinkAliasesModule extends PreserveLinkAliasesModule {
|
||||
public callProcessContent(
|
||||
content: string,
|
||||
newFileName: string,
|
||||
newBasename: string,
|
||||
oldBasename: string,
|
||||
settings: PreserveLinkAliasesSettings,
|
||||
): string {
|
||||
return (this as unknown as {
|
||||
processContent: (
|
||||
c: string,
|
||||
nf: string,
|
||||
nb: string,
|
||||
ob: string,
|
||||
s: PreserveLinkAliasesSettings,
|
||||
) => string;
|
||||
}).processContent(content, newFileName, newBasename, oldBasename, settings);
|
||||
}
|
||||
|
||||
public callGetFilesToProcess(settings: PreserveLinkAliasesSettings): TFile[] {
|
||||
return (this as unknown as {
|
||||
getFilesToProcess: (s: PreserveLinkAliasesSettings) => TFile[];
|
||||
}).getFilesToProcess(settings);
|
||||
}
|
||||
|
||||
public async callHandleRename(
|
||||
file: TFile,
|
||||
oldPath: string,
|
||||
settings: PreserveLinkAliasesSettings,
|
||||
): Promise<void> {
|
||||
await (this as unknown as {
|
||||
handleRename: (f: TFile, op: string, s: PreserveLinkAliasesSettings) => Promise<void>;
|
||||
}).handleRename(file, oldPath, settings);
|
||||
}
|
||||
|
||||
public setVault(vault: Vault): void {
|
||||
(this as unknown as { vault: Vault }).vault = vault;
|
||||
}
|
||||
}
|
||||
|
||||
function makeModule(vault?: Vault): TestablePreserveLinkAliasesModule {
|
||||
const module = new TestablePreserveLinkAliasesModule();
|
||||
if (vault) {
|
||||
module.setVault(vault);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
function makeVault(opts: {
|
||||
mdFiles?: TFile[];
|
||||
allFiles?: TFile[];
|
||||
storage?: Map<TFile, string>;
|
||||
} = {}): Vault {
|
||||
const vault = new Vault();
|
||||
vault.mdFiles = opts.mdFiles ?? [];
|
||||
vault.allFiles = opts.allFiles ?? [];
|
||||
if (opts.storage) {
|
||||
for (const [k, v] of opts.storage) {
|
||||
vault.storage.set(k, v);
|
||||
}
|
||||
}
|
||||
return vault;
|
||||
}
|
||||
|
||||
describe('PreserveLinkAliasesModule', () => {
|
||||
let module: TestablePreserveLinkAliasesModule;
|
||||
|
||||
beforeEach(() => {
|
||||
module = makeModule();
|
||||
});
|
||||
|
||||
// 1. processContent заменяет алиас при переименовании: [[file.md|newname]] → [[file.md|oldname]]
|
||||
describe('processContent', () => {
|
||||
it('заменяет алиас при переименовании: [[file.md|newname]] → [[file.md|oldname]]', () => {
|
||||
const settings: PreserveLinkAliasesSettings = {
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
};
|
||||
|
||||
const result = module.callProcessContent(
|
||||
'See [[file.md|newname]] for details.',
|
||||
'file.md',
|
||||
'newname',
|
||||
'oldname',
|
||||
settings,
|
||||
);
|
||||
|
||||
expect(result).toBe('See [[file.md|oldname]] for details.');
|
||||
});
|
||||
|
||||
// 2. processContent игнорирует ссылки без алиаса (без |): [[file.md]] остаётся без изменений
|
||||
it('игнорирует ссылки без алиаса (без |): [[file.md]] остаётся без изменений', () => {
|
||||
const settings: PreserveLinkAliasesSettings = {
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
};
|
||||
|
||||
const content = 'Plain link: [[file.md]] stays the same.';
|
||||
const result = module.callProcessContent(
|
||||
content,
|
||||
'file.md',
|
||||
'newname',
|
||||
'oldname',
|
||||
settings,
|
||||
);
|
||||
|
||||
expect(result).toBe(content);
|
||||
});
|
||||
|
||||
// 3. processContent игнорирует ссылки, где алиас НЕ равен newBasename
|
||||
it('игнорирует ссылки, где алиас НЕ равен newBasename', () => {
|
||||
const settings: PreserveLinkAliasesSettings = {
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
};
|
||||
|
||||
const content = 'Other alias: [[file.md|otheralias]] is untouched.';
|
||||
const result = module.callProcessContent(
|
||||
content,
|
||||
'file.md',
|
||||
'newname',
|
||||
'oldname',
|
||||
settings,
|
||||
);
|
||||
|
||||
expect(result).toBe(content);
|
||||
});
|
||||
|
||||
// 4a. processContent учитывает флаг processEmbeds: ![[file.md|newname]] → ![[file.md|oldname]] (если true)
|
||||
it('обрабатывает ![[embed]] когда processEmbeds=true', () => {
|
||||
const settings: PreserveLinkAliasesSettings = {
|
||||
processEmbeds: true,
|
||||
processCanvas: false,
|
||||
};
|
||||
|
||||
const result = module.callProcessContent(
|
||||
'Embedded: ![[file.md|newname]] here.',
|
||||
'file.md',
|
||||
'newname',
|
||||
'oldname',
|
||||
settings,
|
||||
);
|
||||
|
||||
expect(result).toBe('Embedded: ![[file.md|oldname]] here.');
|
||||
});
|
||||
|
||||
// 4b. processContent игнорирует (если false)
|
||||
it('игнорирует ![[embed]] когда processEmbeds=false', () => {
|
||||
const settings: PreserveLinkAliasesSettings = {
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
};
|
||||
|
||||
const content = 'Embedded: ![[file.md|newname]] stays untouched.';
|
||||
const result = module.callProcessContent(
|
||||
content,
|
||||
'file.md',
|
||||
'newname',
|
||||
'oldname',
|
||||
settings,
|
||||
);
|
||||
|
||||
expect(result).toBe(content);
|
||||
});
|
||||
});
|
||||
|
||||
// 5. getFilesToProcess включает canvas-файлы при processCanvas=true
|
||||
// 6. getFilesToProcess НЕ включает canvas-файлы при processCanvas=false
|
||||
describe('getFilesToProcess', () => {
|
||||
const mdA = new TFile('notes/a.md');
|
||||
const mdB = new TFile('notes/b.md');
|
||||
const canvasX = new TFile('boards/x.canvas');
|
||||
const pdfF = new TFile('papers/f.pdf');
|
||||
|
||||
it('включает canvas-файлы при processCanvas=true', () => {
|
||||
const vault = makeVault({
|
||||
mdFiles: [mdA, mdB],
|
||||
allFiles: [mdA, mdB, canvasX, pdfF],
|
||||
});
|
||||
const moduleWithVault = makeModule(vault);
|
||||
|
||||
const result = moduleWithVault.callGetFilesToProcess({
|
||||
processEmbeds: false,
|
||||
processCanvas: true,
|
||||
});
|
||||
|
||||
expect(result).toEqual([mdA, mdB, canvasX]);
|
||||
});
|
||||
|
||||
it('НЕ включает canvas-файлы при processCanvas=false', () => {
|
||||
const vault = makeVault({
|
||||
mdFiles: [mdA, mdB],
|
||||
allFiles: [mdA, mdB, canvasX, pdfF],
|
||||
});
|
||||
const moduleWithVault = makeModule(vault);
|
||||
|
||||
const result = moduleWithVault.callGetFilesToProcess({
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
});
|
||||
|
||||
expect(result).toEqual([mdA, mdB]);
|
||||
});
|
||||
});
|
||||
|
||||
// 7. handleRename не вызывает processContent если oldBasename === newBasename
|
||||
describe('handleRename', () => {
|
||||
it('не вызывает processContent если oldBasename === newBasename', async () => {
|
||||
const file = new TFile('notes/note.md');
|
||||
const vault = makeVault({
|
||||
mdFiles: [file],
|
||||
storage: new Map([[file, 'See [[other.md|note]] here.']]),
|
||||
});
|
||||
const moduleWithVault = makeModule(vault);
|
||||
|
||||
await moduleWithVault.callHandleRename(file, 'notes/note.md', {
|
||||
processEmbeds: false,
|
||||
processCanvas: false,
|
||||
});
|
||||
|
||||
expect(vault.readCalls).toEqual([]);
|
||||
expect(vault.modifyCalls).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user