mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-20 07:40:35 +08:00
- Redis Key 搜索默认补全包含匹配并支持 ASCII 大小写不敏感 - Redis 标签页增加连接名与 host 摘要,区分同名 db 标签 - 抽取 inputAutoCap、redisSearchPattern、tabDisplay 共享工具并补充回归测试 - 覆盖连接配置、Redis 搜索、表设计、表概览和数据表筛选输入的自动纠正问题 - 在 macOS 文本输入面板关闭局部毛玻璃,修复输入法切换出现透明框
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { normalizeRedisSearchDraftChange, normalizeRedisSearchInput } from './redisSearchPattern';
|
|
|
|
describe('normalizeRedisSearchInput', () => {
|
|
it('returns wildcard for empty input', () => {
|
|
expect(normalizeRedisSearchInput('')).toEqual({
|
|
keyword: '',
|
|
pattern: '*',
|
|
});
|
|
});
|
|
|
|
it('wraps plain keywords with wildcard for contains matching', () => {
|
|
expect(normalizeRedisSearchInput('order')).toEqual({
|
|
keyword: 'order',
|
|
pattern: '*[oO][rR][dD][eE][rR]*',
|
|
});
|
|
});
|
|
|
|
it('builds ascii case-insensitive patterns for letter keywords', () => {
|
|
expect(normalizeRedisSearchInput('agent')).toEqual({
|
|
keyword: 'agent',
|
|
pattern: '*[aA][gG][eE][nN][tT]*',
|
|
});
|
|
});
|
|
|
|
it('escapes redis glob special characters as literals', () => {
|
|
expect(normalizeRedisSearchInput('user:*:[id]?')).toEqual({
|
|
keyword: 'user:*:[id]?',
|
|
pattern: '*[uU][sS][eE][rR]:\\*:\\[[iI][dD]\\]\\?*',
|
|
});
|
|
});
|
|
|
|
it('marks empty draft changes for immediate reset search', () => {
|
|
expect(normalizeRedisSearchDraftChange('')).toEqual({
|
|
keyword: '',
|
|
pattern: '*',
|
|
shouldSearchImmediately: true,
|
|
});
|
|
});
|
|
});
|