refactor: 重构一下档案搜索功能 支持拼音微信号等

This commit is contained in:
电摇小子
2026-09-03 23:38:12 +08:00
parent bde3bc537f
commit 21e299942b
17 changed files with 365 additions and 44 deletions
+15 -1
View File
@@ -14,7 +14,7 @@ const contact: Contact = {
}
describe('filterContacts', () => {
it.each(['Shinven', '小号', '工作', 'abc123', 'WECHAT_ABC', 'WXID_xxy']) (
it.each(['Shinven', '小号', '工作', 'gongzuoshouji', 'gzsj', 'abc123', 'WECHAT_ABC', 'WXID_xxy'])(
'matches all contact identity fields with %s',
(query) => {
expect(filterContacts([contact], ` ${query} `)).toEqual([contact])
@@ -26,4 +26,18 @@ describe('filterContacts', () => {
expect(filterContacts(list, ' ')).toBe(list)
expect(filterContacts(list, 'not-found')).toEqual([])
})
it('matches pinyin when the Chinese name is stored in m_nsNickName', () => {
const list = [{ ...contact, remark: '', wechatNickname: '' }]
expect(filterContacts(list, 'xiaohao')).toEqual(list)
expect(filterContacts(list, 'xh')).toEqual(list)
})
it('matches pinyin for a dedicated Chinese remark', () => {
const list = [{ ...contact, m_nsNickName: 'Shinven', remark: '小号' }]
expect(filterContacts(list, 'xiaohao')).toEqual(list)
expect(filterContacts(list, 'xh')).toEqual(list)
})
})