mirror of
https://github.com/unraid/api.git
synced 2026-01-06 16:49:49 -06:00
This gets the original 3 component tests refactored to better follow the Vue Testing Library philosophy and test behavior. This also adds a new test file for the server store. Additional batches of tests will be added in proceeding PR's. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Streamlined internal code organization and improved maintenance through refined import structures and cleanup of redundant files. - **Tests** - Expanded and restructured automated tests across core components, including new test files for `Auth`, `DownloadApiLogs`, and `KeyActions` to ensure robust behavior. - Enhanced test configuration and mock implementations for a more reliable, consistent testing environment. - Introduced best practices for testing Vue components and Pinia stores. These updates optimize performance and stability behind the scenes without altering the end-user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mdatelle <mike@datelle.net>
41 lines
807 B
TypeScript
41 lines
807 B
TypeScript
import { config } from '@vue/test-utils';
|
|
|
|
import { createTestingPinia } from '@pinia/testing';
|
|
import { afterAll, beforeAll, vi } from 'vitest';
|
|
|
|
// Import mocks
|
|
import './mocks/shared-callbacks.js';
|
|
import './mocks/ui-components.js';
|
|
import './mocks/stores/index.js';
|
|
import './mocks/services/index.js';
|
|
|
|
// Configure Vue Test Utils
|
|
config.global.plugins = [
|
|
createTestingPinia({
|
|
createSpy: vi.fn,
|
|
}),
|
|
// Simple mock for i18n
|
|
{
|
|
install: vi.fn(),
|
|
},
|
|
];
|
|
|
|
// Set a timeout for tests
|
|
vi.setConfig({
|
|
testTimeout: 10000,
|
|
hookTimeout: 10000,
|
|
});
|
|
|
|
// Mock fetch
|
|
globalThis.fetch = vi.fn(() =>
|
|
Promise.resolve({
|
|
ok: true,
|
|
json: () => Promise.resolve({}),
|
|
text: () => Promise.resolve(''),
|
|
} as Response)
|
|
);
|
|
|
|
// Global setup and cleanup
|
|
beforeAll(() => {});
|
|
afterAll(() => {});
|