brand new unit tests finally
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m19s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m19s
This commit is contained in:
@@ -21,10 +21,6 @@ describe('VoiceLabPage', () => {
|
|||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.unstubAllGlobals();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render the initial state correctly', () => {
|
it('should render the initial state correctly', () => {
|
||||||
render(<VoiceLabPage />);
|
render(<VoiceLabPage />);
|
||||||
expect(screen.getByRole('heading', { name: /admin voice lab/i })).toBeInTheDocument();
|
expect(screen.getByRole('heading', { name: /admin voice lab/i })).toBeInTheDocument();
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import type { MasterGroceryItem } from '../types';
|
|||||||
|
|
||||||
// Mock the Google GenAI library
|
// Mock the Google GenAI library
|
||||||
const mockGenerateContent = vi.fn();
|
const mockGenerateContent = vi.fn();
|
||||||
vi.mock('@google/genai', () => {
|
vi.mock('@google/genai', () => ({
|
||||||
// This mock now correctly simulates a class that can be instantiated with `new`.
|
// Use a standard function to correctly mock a class constructor that can be called with `new`.
|
||||||
const mockGoogleGenAI = vi.fn().mockImplementation(() => ({
|
GoogleGenAI: vi.fn(function() {
|
||||||
|
return {
|
||||||
getGenerativeModel: vi.fn(() => ({ generateContent: mockGenerateContent })),
|
getGenerativeModel: vi.fn(() => ({ generateContent: mockGenerateContent })),
|
||||||
}));
|
};
|
||||||
return { GoogleGenAI: mockGoogleGenAI };
|
}),
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Mock fs/promises
|
// Mock fs/promises
|
||||||
vi.mock('fs/promises');
|
vi.mock('fs/promises');
|
||||||
|
|||||||
@@ -62,7 +62,10 @@ vi.mock('pdfjs-dist', () => ({
|
|||||||
|
|
||||||
// Mock react-hot-toast and the notification service that uses it.
|
// Mock react-hot-toast and the notification service that uses it.
|
||||||
vi.mock('react-hot-toast', () => ({
|
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', () => ({
|
vi.mock('../../services/notificationService', () => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user