@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.
44 lines (34 loc) • 1.19 kB
text/typescript
import { act, renderHook, waitFor } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { withSWR } from '~test-utils';
import { DEFAULT_PREFERENCE } from '@/const/user';
import { userService } from '@/services/user';
import { useUserStore } from '@/store/user';
import { UserGuide, UserPreference } from '@/types/user';
beforeEach(() => {
vi.clearAllMocks();
});
afterEach(() => {
vi.restoreAllMocks();
});
describe('createPreferenceSlice', () => {
describe('updateGuideState', () => {
it('should update guide state', () => {
const { result } = renderHook(() => useUserStore());
const guide: UserGuide = { topic: true };
act(() => {
result.current.updateGuideState(guide);
});
expect(result.current.preference.guide!.topic).toBeTruthy();
});
});
describe('updatePreference', () => {
it('should update preference', () => {
const { result } = renderHook(() => useUserStore());
act(() => {
result.current.updatePreference({ hideSyncAlert: true });
});
expect(result.current.preference.hideSyncAlert).toEqual(true);
});
});
});