Download apps/vscode/test/webview/mention-insert.test.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/test/webview/mention-insert.test.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vscode/test/webview/mention-insert.test.ts
-
curl -L -o mention-insert.test.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vscode/test/webview/mention-insert.test.ts
1.57 kB
| import { describe, expect, it } from 'vitest'; | |
| import { computeMentionInsert } from '@/components/inputarea/utils'; | |
| describe('computeMentionInsert', () => { | |
| it('replaces the active token with the mention and moves the cursor past it', () => { | |
| const result = computeMentionInsert({ | |
| text: 'check @ap', | |
| cursorPos: 9, | |
| filePath: 'src/app.ts', | |
| activeToken: { start: 6 }, | |
| isAppend: false, | |
| }); | |
| expect(result.newText).toBe('check @src/app.ts '); | |
| expect(result.newCursorPos).toBe(result.newText.length); | |
| }); | |
| it('appends the mention when there is no active token', () => { | |
| const result = computeMentionInsert({ | |
| text: 'hi ', | |
| cursorPos: 3, | |
| filePath: 'a.ts', | |
| activeToken: null, | |
| isAppend: true, | |
| }); | |
| expect(result.newText).toBe('hi @a.ts '); | |
| expect(result.newCursorPos).toBe(result.newText.length); | |
| }); | |
| it('quotes a path containing spaces so whitespace cannot split the mention', () => { | |
| const result = computeMentionInsert({ | |
| text: '@my', | |
| cursorPos: 3, | |
| filePath: 'My Folder/app.ts', | |
| activeToken: { start: 0 }, | |
| isAppend: false, | |
| }); | |
| expect(result.newText).toBe('@"My Folder/app.ts" '); | |
| expect(result.newCursorPos).toBe(result.newText.length); | |
| }); | |
| it('quotes a path containing spaces in append mode', () => { | |
| const result = computeMentionInsert({ | |
| text: '', | |
| cursorPos: 0, | |
| filePath: 'My Folder', | |
| activeToken: null, | |
| isAppend: true, | |
| }); | |
| expect(result.newText).toBe('@"My Folder" '); | |
| }); | |
| }); | |