brand new unit tests finally
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m19s

This commit is contained in:
2025-11-28 00:07:23 -08:00
parent 7c91c94b1f
commit 14ab073fab
3 changed files with 11 additions and 11 deletions

View File

@@ -21,10 +21,6 @@ describe('VoiceLabPage', () => {
vi.clearAllMocks();
});
afterEach(() => {
vi.unstubAllGlobals();
});
it('should render the initial state correctly', () => {
render(<VoiceLabPage />);
expect(screen.getByRole('heading', { name: /admin voice lab/i })).toBeInTheDocument();

View File

@@ -5,13 +5,14 @@ import type { MasterGroceryItem } from '../types';
// Mock the Google GenAI library
const mockGenerateContent = vi.fn();
vi.mock('@google/genai', () => {
// This mock now correctly simulates a class that can be instantiated with `new`.
const mockGoogleGenAI = vi.fn().mockImplementation(() => ({
vi.mock('@google/genai', () => ({
// Use a standard function to correctly mock a class constructor that can be called with `new`.
GoogleGenAI: vi.fn(function() {
return {
getGenerativeModel: vi.fn(() => ({ generateContent: mockGenerateContent })),
}));
return { GoogleGenAI: mockGoogleGenAI };
});
};
}),
}));
// Mock fs/promises
vi.mock('fs/promises');

View File

@@ -62,7 +62,10 @@ vi.mock('pdfjs-dist', () => ({
// Mock react-hot-toast and the notification service that uses it.
vi.mock('react-hot-toast', () => ({
default: { success: vi.fn(), error: vi.fn() },
// Mock the default export (the `toast` object) and the named export `Toaster`.
default: { success: vi.fn(), error: vi.fn(), loading: vi.fn() },
// The Toaster component can be mocked as a simple function that returns null.
Toaster: () => null,
}));
vi.mock('../../services/notificationService', () => ({