返回 ViMax
slashCommands.test.ts
根目录 / web / src / slashCommands.test.ts
1 import {describe, expect, it} from 'vitest';
2 import {matchingSlashCommands, shouldShowSlashCommands} from './slashCommands';
3
4 describe('slash command matching', () => {
5 it('matches command prefixes and exposes highlighted segments', () => {
6 expect(matchingSlashCommands('/co')[0]).toMatchObject({matchedPrefix: '/co', unmatchedSuffix: 'mpact'});
7 });
8
9 it('only opens for idle slash input', () => {
10 expect(shouldShowSlashCommands('/', false)).toBe(true);
11 expect(shouldShowSlashCommands('/co', true)).toBe(false);
12 expect(shouldShowSlashCommands('hello', false)).toBe(false);
13 });
14 });
15
15 lines TYPESCRIPT