"use strict";
/**
 * @jest-environment jsdom
 */
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("@testing-library/react");
const usePostOnboardingDeeplinkHandler_1 = require("./usePostOnboardingDeeplinkHandler");
const devices_1 = require("@ledgerhq/devices");
const reducer_1 = require("../reducer");
const useAllPostOnboardingActionsCompleted_1 = require("./useAllPostOnboardingActionsCompleted");
const usePostOnboardingHubState_1 = require("./usePostOnboardingHubState");
const mock_1 = require("../mock");
const mockedDispatch = jest.fn();
jest.mock("react-redux", () => ({
    useSelector: fun => fun(),
    useDispatch: () => mockedDispatch,
}));
jest.mock("../reducer");
jest.mock("./useAllPostOnboardingActionsCompleted");
jest.mock("./usePostOnboardingHubState");
const mockedUseAllCompleted = jest.mocked(useAllPostOnboardingActionsCompleted_1.useAllPostOnboardingActionsCompleted);
const mockedDismissedSelector = jest.mocked(reducer_1.walletPostOnboardingEntryPointDismissedSelector);
const mockedDeviceModelIdSelector = jest.mocked(reducer_1.postOnboardingDeviceModelIdSelector);
const mockedUsePostOnboardingHubState = jest.mocked(usePostOnboardingHubState_1.usePostOnboardingHubState);
const mockedStateNoActionsCompleted = {
    deviceModelId: devices_1.DeviceModelId.stax,
    lastActionCompleted: null,
    actionsState: [
        { ...mock_1.claimTestMock, completed: false },
        { ...mock_1.personalizeTestMock, completed: false },
        { ...mock_1.migrateAssetsTestMock, completed: false },
    ],
    postOnboardingInProgress: false,
};
describe("usePostOnboardingDeeplinkHandler", () => {
    beforeEach(() => {
        mockedUseAllCompleted.mockClear();
        mockedDismissedSelector.mockClear();
        mockedDeviceModelIdSelector.mockClear();
        mockedDispatch.mockClear();
        mockedUsePostOnboardingHubState.mockClear();
    });
    test("should navigate to the post onboarding hub when called with a stax device model id", () => {
        mockedDismissedSelector.mockReturnValue(false);
        mockedUseAllCompleted.mockReturnValue(false);
        mockedDeviceModelIdSelector.mockReturnValue(devices_1.DeviceModelId.stax);
        mockedUsePostOnboardingHubState.mockReturnValue(mockedStateNoActionsCompleted);
        const navigateToHome = jest.fn();
        const navigateToPostOnboardingHub = jest.fn();
        const { result } = (0, react_1.renderHook)(() => (0, usePostOnboardingDeeplinkHandler_1.usePostOnboardingDeeplinkHandler)(navigateToHome, navigateToPostOnboardingHub));
        (0, react_1.act)(() => {
            result.current("stax");
        });
        expect(navigateToPostOnboardingHub).toHaveBeenCalled();
        expect(navigateToHome).not.toHaveBeenCalled();
    });
    test("should navigate to the home when called with no device parameter", () => {
        mockedDismissedSelector.mockReturnValue(false);
        mockedUseAllCompleted.mockReturnValue(false);
        mockedDeviceModelIdSelector.mockReturnValue(devices_1.DeviceModelId.nanoSP);
        mockedUsePostOnboardingHubState.mockReturnValue(mockedStateNoActionsCompleted);
        const navigateToHome = jest.fn();
        const navigateToPostOnboardingHub = jest.fn();
        const { result } = (0, react_1.renderHook)(() => (0, usePostOnboardingDeeplinkHandler_1.usePostOnboardingDeeplinkHandler)(navigateToHome, navigateToPostOnboardingHub));
        (0, react_1.act)(() => {
            result.current();
        });
        expect(navigateToPostOnboardingHub).not.toHaveBeenCalled();
        expect(navigateToHome).toHaveBeenCalled();
    });
});
//# sourceMappingURL=usePostOnboardingDeeplinkHandler.test.js.map