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:
Eli Bosley
2025-12-30 12:16:09 -05:00
parent 92bc43295c
commit fcf30006c4

View File

@@ -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();