mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Improve tests and add useGitOps hook test
This commit is contained in:
@@ -157,8 +157,6 @@ describe('fileHelpers', () => {
|
||||
});
|
||||
|
||||
it('uses the API base URL correctly', () => {
|
||||
// Test that the function uses the expected API base URL
|
||||
// Note: The API_BASE_URL is imported at module load time, so we test the expected behavior
|
||||
const url = getFileUrl('test', 'file.md');
|
||||
expect(url).toBe(
|
||||
'http://localhost:8080/api/v1/workspaces/test/files/file.md'
|
||||
|
||||
@@ -278,6 +278,7 @@ describe('remarkWikiLinks', () => {
|
||||
|
||||
expect(result.toString()).toContain('Spaces');
|
||||
// Should not call API for empty/whitespace-only links
|
||||
expect(fileApi.lookupFileByName).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles nested brackets', async () => {
|
||||
@@ -319,19 +320,5 @@ describe('remarkWikiLinks', () => {
|
||||
// Should not call API when workspace is empty
|
||||
expect(fileApi.lookupFileByName).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not process links when workspace is not provided', async () => {
|
||||
const processor = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkWikiLinks, '')
|
||||
.use(remarkStringify);
|
||||
|
||||
const markdown = '[[test]]';
|
||||
|
||||
const result = await processor.process(markdown);
|
||||
|
||||
expect(result.toString()).toContain('test');
|
||||
expect(fileApi.lookupFileByName).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -233,6 +233,13 @@ export function remarkWikiLinks(workspaceName: string) {
|
||||
}
|
||||
|
||||
try {
|
||||
// Skip API call for empty or whitespace-only filenames
|
||||
if (!match.fileName.trim()) {
|
||||
newNodes.push(createTextNode(match.fullMatch));
|
||||
lastIndex = match.index + match.fullMatch.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
const lookupFileName: string = match.isImage
|
||||
? match.fileName
|
||||
: addMarkdownExtension(match.fileName);
|
||||
|
||||
Reference in New Issue
Block a user