Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -1,61 +1,61 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { applyFileMentionReplacement, findActiveFileMention } from './file-mention-autocomplete'
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyFileMentionReplacement, findActiveFileMention } from "./file-mention-autocomplete";
|
||||
|
||||
describe('findActiveFileMention', () => {
|
||||
it('detects mentions at the start of input', () => {
|
||||
describe("findActiveFileMention", () => {
|
||||
it("detects mentions at the start of input", () => {
|
||||
const mention = findActiveFileMention({
|
||||
text: '@src/components',
|
||||
cursorIndex: '@src/components'.length,
|
||||
})
|
||||
text: "@src/components",
|
||||
cursorIndex: "@src/components".length,
|
||||
});
|
||||
expect(mention).toEqual({
|
||||
start: 0,
|
||||
end: '@src/components'.length,
|
||||
query: 'src/components',
|
||||
})
|
||||
})
|
||||
end: "@src/components".length,
|
||||
query: "src/components",
|
||||
});
|
||||
});
|
||||
|
||||
it('detects mentions in the middle of input using cursor position', () => {
|
||||
const text = 'read "@src/com" before merging'
|
||||
const cursorIndex = text.indexOf('"') + 9
|
||||
it("detects mentions in the middle of input using cursor position", () => {
|
||||
const text = 'read "@src/com" before merging';
|
||||
const cursorIndex = text.indexOf('"') + 9;
|
||||
const mention = findActiveFileMention({
|
||||
text,
|
||||
cursorIndex,
|
||||
})
|
||||
});
|
||||
expect(mention).toEqual({
|
||||
start: text.indexOf('@'),
|
||||
start: text.indexOf("@"),
|
||||
end: cursorIndex,
|
||||
query: 'src/com',
|
||||
})
|
||||
})
|
||||
query: "src/com",
|
||||
});
|
||||
});
|
||||
|
||||
it('returns null when cursor is outside the mention token', () => {
|
||||
const text = 'please review @src/components now'
|
||||
it("returns null when cursor is outside the mention token", () => {
|
||||
const text = "please review @src/components now";
|
||||
const mention = findActiveFileMention({
|
||||
text,
|
||||
cursorIndex: text.length,
|
||||
})
|
||||
expect(mention).toBeNull()
|
||||
})
|
||||
})
|
||||
});
|
||||
expect(mention).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyFileMentionReplacement', () => {
|
||||
it('replaces only the active @query segment with a quoted relative path', () => {
|
||||
const text = 'open @src/com next'
|
||||
describe("applyFileMentionReplacement", () => {
|
||||
it("replaces only the active @query segment with a quoted relative path", () => {
|
||||
const text = "open @src/com next";
|
||||
const next = applyFileMentionReplacement({
|
||||
text,
|
||||
mention: { start: 5, end: 13, query: 'src/com' },
|
||||
relativePath: 'src/components/chat.tsx',
|
||||
})
|
||||
expect(next).toBe('open "src/components/chat.tsx" next')
|
||||
})
|
||||
mention: { start: 5, end: 13, query: "src/com" },
|
||||
relativePath: "src/components/chat.tsx",
|
||||
});
|
||||
expect(next).toBe('open "src/components/chat.tsx" next');
|
||||
});
|
||||
|
||||
it('escapes double quotes in replacement path', () => {
|
||||
const text = '@foo'
|
||||
it("escapes double quotes in replacement path", () => {
|
||||
const text = "@foo";
|
||||
const next = applyFileMentionReplacement({
|
||||
text,
|
||||
mention: { start: 0, end: 4, query: 'foo' },
|
||||
mention: { start: 0, end: 4, query: "foo" },
|
||||
relativePath: 'src/"quoted".ts',
|
||||
})
|
||||
expect(next).toBe('"src/\\"quoted\\".ts"')
|
||||
})
|
||||
})
|
||||
});
|
||||
expect(next).toBe('"src/\\"quoted\\".ts"');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user