mirror of
https://github.com/unraid/api.git
synced 2026-01-06 00:30:22 -06:00
refactor(tests): improve test setup for ActivationPluginsStep component
- Refactored the test setup in `ActivationPluginsStep.test.ts` to utilize `vi.hoisted` for better organization of mock functions. - Updated the error handling in the test case for installation failure to use `mockRejectedValue` instead of `mockRejectedValueOnce`, ensuring consistent behavior during tests. These changes enhance the clarity and reliability of the test suite for the ActivationPluginsStep component.
This commit is contained in:
@@ -7,8 +7,10 @@ import ActivationPluginsStep from '~/components/Activation/ActivationPluginsStep
|
||||
import { PluginInstallStatus } from '~/composables/gql/graphql';
|
||||
import { createTestI18n } from '../../utils/i18n';
|
||||
|
||||
const installPluginMock = vi.fn();
|
||||
const useQueryMock = vi.fn();
|
||||
const { installPluginMock, useQueryMock } = vi.hoisted(() => ({
|
||||
installPluginMock: vi.fn(),
|
||||
useQueryMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@unraid/ui', () => ({
|
||||
BrandButton: {
|
||||
@@ -117,7 +119,7 @@ describe('ActivationPluginsStep', () => {
|
||||
});
|
||||
|
||||
it('shows error message when installation fails', async () => {
|
||||
installPluginMock.mockRejectedValueOnce(new Error('install failed'));
|
||||
installPluginMock.mockRejectedValue(new Error('install failed'));
|
||||
|
||||
const { wrapper, props } = mountComponent();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user