Skip to content

Commit

Permalink
✅ test: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jan 23, 2024
1 parent 4622953 commit a8d200c
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/store/global/slices/settings/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { describe, expect, it, vi } from 'vitest';
import { DEFAULT_AGENT, DEFAULT_SETTINGS } from '@/const/settings';
import { useGlobalStore } from '@/store/global';
import { SettingsTabs } from '@/store/global/initialState';
import { LobeAgentSettings } from '@/types/session';
import { LanguageModel } from '@/types/llm';
import { LobeAgentSettings, SessionGroupItem } from '@/types/session';
import { GlobalSettings, OpenAIConfig } from '@/types/settings';

beforeEach(() => {
Expand All @@ -17,6 +18,23 @@ vi.mock('@/utils/uuid', () => ({
}));

describe('SettingsAction', () => {
describe('addCustomGroup', () => {
it('should add a custom group and update session group keys', () => {
const { result } = renderHook(() => useGlobalStore());

act(() => {
const groupId = result.current.addCustomGroup('New Group');
expect(groupId).toBe('unique-id');
});

expect(result.current.settings.sessionCustomGroups).toContainEqual({
id: 'unique-id',
name: 'New Group',
});
expect(result.current.preference.sessionGroupKeys).toContain('unique-id');
});
});

describe('importAppSettings', () => {
it('should import app settings', () => {
const { result } = renderHook(() => useGlobalStore());
Expand Down Expand Up @@ -97,6 +115,19 @@ describe('SettingsAction', () => {
});
});

describe('updateCustomGroup', () => {
it('should update custom groups', () => {
const { result } = renderHook(() => useGlobalStore());
const updatedGroups: SessionGroupItem[] = [{ id: 'group-id', name: 'Updated Group' }];

act(() => {
result.current.updateCustomGroup(updatedGroups);
});

expect(result.current.settings.sessionCustomGroups).toEqual(updatedGroups);
});
});

describe('updateDefaultAgent', () => {
it('should update default agent settings', () => {
const { result } = renderHook(() => useGlobalStore());
Expand Down

0 comments on commit a8d200c

Please sign in to comment.