Files
WechatExplorer/tests/unit/contact-search.test.ts
T
Wxw-Gu 719ffa0a24 feat: 优化档案搜索与头像
新增退群监控开关
发送限速
2026-09-03 18:12:29 +08:00

30 lines
906 B
TypeScript

import { describe, expect, it } from 'vitest'
import type { Contact } from '../../src/shared/types'
import { filterContacts } from '../../src/renderer/src/utils/contact-search'
const contact: Contact = {
m_nsUsrName: 'wxid_XxYyZz',
m_nsNickName: '小号',
md5: 'fixture',
type: 'user',
remark: '工作手机',
wechatNickname: 'Shinven',
alias: 'abc123',
wechatId: 'wechat_abc123'
}
describe('filterContacts', () => {
it.each(['Shinven', '小号', '工作', 'abc123', 'WECHAT_ABC', 'WXID_xxy']) (
'matches all contact identity fields with %s',
(query) => {
expect(filterContacts([contact], ` ${query} `)).toEqual([contact])
}
)
it('returns the original list for a blank query and excludes unrelated contacts', () => {
const list = [contact]
expect(filterContacts(list, ' ')).toBe(list)
expect(filterContacts(list, 'not-found')).toEqual([])
})
})