UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

66 lines (59 loc) 2.34 kB
import { describe, expect, it } from 'vitest'; import { DalleManifest } from '@/tools/dalle'; import { ToolStoreState, initialState } from '../../initialState'; import { builtinToolSelectors } from './selectors'; describe('builtinToolSelectors', () => { describe('metaList', () => { it('should return meta list excluding Dalle when showDalle is false', () => { const state = { ...initialState, builtinTools: [ { identifier: 'tool-1', manifest: { meta: { title: 'Tool 1' } } }, { identifier: DalleManifest.identifier, manifest: { meta: { title: 'Dalle' } } }, ], } as ToolStoreState; const result = builtinToolSelectors.metaList(false)(state); expect(result).toEqual([ { author: 'LobeHub', identifier: 'tool-1', meta: { title: 'Tool 1' }, type: 'builtin' }, ]); }); it('should include Dalle when showDalle is true', () => { const state = { ...initialState, builtinTools: [ { identifier: 'tool-1', manifest: { meta: { title: 'Tool 1' } } }, { identifier: DalleManifest.identifier, manifest: { meta: { title: 'Dalle' } } }, ], } as ToolStoreState; const result = builtinToolSelectors.metaList(true)(state); expect(result).toEqual([ { author: 'LobeHub', identifier: 'tool-1', meta: { title: 'Tool 1' }, type: 'builtin' }, { author: 'LobeHub', identifier: DalleManifest.identifier, meta: { title: 'Dalle' }, type: 'builtin', }, ]); }); it('should hide tool when not need visible with hidden', () => { const state = { ...initialState, builtinTools: [ { identifier: 'tool-1', hidden: true, manifest: { meta: { title: 'Tool 1' } } }, { identifier: DalleManifest.identifier, manifest: { meta: { title: 'Dalle' } } }, ], } as ToolStoreState; const result = builtinToolSelectors.metaList(false)(state); expect(result).toEqual([]); }); it('should return an empty list if no builtin tools are available', () => { const state: ToolStoreState = { ...initialState, builtinTools: [], }; const result = builtinToolSelectors.metaList(false)(state); expect(result).toEqual([]); }); }); });