From 176430a31f8d19cd125cad19a45796b1c305bae2 Mon Sep 17 00:00:00 2001 From: icarus Date: Wed, 6 Aug 2025 20:09:59 +0800 Subject: [PATCH] =?UTF-8?q?test(match):=20=E6=9B=B4=E6=96=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=8F=90=E4=BE=9B=E5=95=86=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E4=BB=A5=E5=8C=B9=E9=85=8Did=E8=80=8C?= =?UTF-8?q?=E9=9D=9Ename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/utils/__tests__/match.test.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/utils/__tests__/match.test.ts b/src/renderer/src/utils/__tests__/match.test.ts index 0e12031cef..a363220f45 100644 --- a/src/renderer/src/utils/__tests__/match.test.ts +++ b/src/renderer/src/utils/__tests__/match.test.ts @@ -1,4 +1,4 @@ -import type { Model, Provider } from '@renderer/types' +import type { Model, Provider, SystemProvider } from '@renderer/types' import { describe, expect, it, vi } from 'vitest' import { includeKeywords, matchKeywordsInModel, matchKeywordsInProvider, matchKeywordsInString } from '../match' @@ -20,10 +20,10 @@ describe('match', () => { models: [], isSystem: false } - const sysProvider: Provider = { + const sysProvider: SystemProvider = { ...provider, - id: 'sys', - name: 'SystemProvider', + id: 'dashscope', + name: 'doesnt matter', isSystem: true } @@ -82,9 +82,9 @@ describe('match', () => { expect(matchKeywordsInProvider('foo', provider)).toBe(false) }) - it('should match i18n name for system provider', () => { - expect(matchKeywordsInProvider('sys', sysProvider)).toBe(true) - expect(matchKeywordsInProvider('SystemProvider', sysProvider)).toBe(true) + it('should match provider for system provider', () => { + // system provider 测 id,non-system provider 测 name + expect(matchKeywordsInProvider('dashscope', sysProvider)).toBe(true) }) }) @@ -108,9 +108,10 @@ describe('match', () => { }) it('should match model name and i18n provider name for system provider', () => { - expect(matchKeywordsInModel('gpt-4.1 sys', model, sysProvider)).toBe(true) - expect(matchKeywordsInModel('sys', model, sysProvider)).toBe(true) - expect(matchKeywordsInModel('SystemProvider', model, sysProvider)).toBe(true) + expect(matchKeywordsInModel('gpt-4.1 dashscope', model, sysProvider)).toBe(true) + expect(matchKeywordsInModel('dashscope', model, sysProvider)).toBe(true) + // system provider 不会直接用 name 检索 + expect(matchKeywordsInModel('doesnt matter', model, sysProvider)).toBe(false) }) it('should match model by id when name is customized', () => {