char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Linting & Formatting scripts (#26819)92d1bb0c9

char/aliceai-t5-moe
1.6 KiB51 linesraw
1import { findCommandToken, takeCommandDismissSnapshot } from '$lib/utils';
2import { describe, expect, it } from 'vitest';
3
4describe('findCommandToken', () => {
5	it('returns null when the value does not start with a slash', () => {
6		expect(findCommandToken('hello /prompt')).toBeNull();
7		expect(findCommandToken('')).toBeNull();
8		expect(findCommandToken('prompt')).toBeNull();
9	});
10
11	it('parses a bare slash', () => {
12		expect(findCommandToken('/')).toEqual({ args: '', end: 1, name: '' });
13	});
14
15	it('parses a command name with no args', () => {
16		expect(findCommandToken('/prompt')).toEqual({ args: '', end: 7, name: 'prompt' });
17	});
18
19	it('parses a command name followed by a space', () => {
20		expect(findCommandToken('/prompt ')).toEqual({ args: '', end: 8, name: 'prompt' });
21	});
22
23	it('parses args after the command name', () => {
24		expect(findCommandToken('/prompt rev')).toEqual({ args: 'rev', end: 11, name: 'prompt' });
25	});
26
27	it('parses multi-word args', () => {
28		expect(findCommandToken('/prompt  review  code ')).toEqual({
29			args: ' review  code ',
30			end: 22,
31			name: 'prompt'
32		});
33	});
34
35	it('treats the whole run as the name when there is no space', () => {
36		expect(findCommandToken('/promptx')).toEqual({ args: '', end: 8, name: 'promptx' });
37	});
38});
39
40describe('takeCommandDismissSnapshot', () => {
41	it('returns null when there is no command token', () => {
42		expect(takeCommandDismissSnapshot('hello')).toBeNull();
43	});
44
45	it('captures the name and args', () => {
46		expect(takeCommandDismissSnapshot('/prompt rev')).toEqual({
47			args: 'rev',
48			name: 'prompt'
49		});
50	});
51});