Files
plex-playlist/frontend/src/main.test.ts

41 lines
1013 B
TypeScript
Raw Normal View History

import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock Vue's createApp
const mockMount = vi.fn();
const mockApp = {
mount: mockMount,
};
const mockCreateApp = vi.fn(() => mockApp);
// Mock the App component
const mockAppComponent = {};
vi.mock('vue', () => ({
createApp: mockCreateApp,
}));
vi.mock('./App.vue', () => ({
default: mockAppComponent,
}));
describe('main.ts', () => {
beforeEach(() => {
vi.clearAllMocks();
// Clear the module cache to ensure fresh imports
vi.resetModules();
});
it('should create Vue app and mount to #app', async () => {
// Import the module after setting up mocks
await import('./main');
// Verify createApp was called with the App component
expect(mockCreateApp).toHaveBeenCalledWith(mockAppComponent);
expect(mockCreateApp).toHaveBeenCalledTimes(1);
// Verify mount was called with #app selector
expect(mockMount).toHaveBeenCalledWith('#app');
expect(mockMount).toHaveBeenCalledTimes(1);
});
});