diff --git a/app/src/organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.tsx b/app/src/organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.tsx index d672bcd9098..1d956a507d9 100644 --- a/app/src/organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.tsx +++ b/app/src/organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal.tsx @@ -23,10 +23,10 @@ export function DeckConfigurationDiscardChangesModal({ setShowConfirmationModal, }: DeckConfigurationDiscardChangesModalProps): JSX.Element { const { t } = useTranslation('device_details') + const history = useHistory() const modalHeader: ModalHeaderBaseProps = { title: t('changes_will_be_lost'), } - const history = useHistory() const handleDiscard = (): void => { setShowConfirmationModal(false) diff --git a/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx b/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx index b51e17ce500..33b112e1043 100644 --- a/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx +++ b/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx @@ -1,22 +1,20 @@ import * as React from 'react' import { fireEvent, screen } from '@testing-library/react' import { describe, it, beforeEach, vi, expect } from 'vitest' +import { useHistory } from 'react-router-dom' import { renderWithProviders } from '../../../__testing-utils__' import { i18n } from '../../../i18n' import { DeckConfigurationDiscardChangesModal } from '../DeckConfigurationDiscardChangesModal' -import type * as ReactRouterDom from 'react-router-dom' - const mockFunc = vi.fn() const mockGoBack = vi.fn() -const mockPush = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const reactRouterDom = await importOriginal() + const actual = await importOriginal() return { - ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + ...actual, + useHistory: () => ({ goBack: mockGoBack }), } })