@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
48 lines • 2.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @jest-environment jsdom
*/
const react_1 = require("@testing-library/react");
const reducer_1 = require("../reducer");
const usePostOnboardingEntryPointVisibleOnWallet_1 = require("./usePostOnboardingEntryPointVisibleOnWallet");
const useAutoDismissPostOnboardingEntryPoint_1 = require("./useAutoDismissPostOnboardingEntryPoint");
const mockedDispatch = jest.fn();
jest.mock("react-redux", () => ({
useSelector: fun => fun(),
useDispatch: () => mockedDispatch,
}));
jest.mock("../reducer");
jest.mock("./useAllPostOnboardingActionsCompleted");
jest.mock("./usePostOnboardingEntryPointVisibleOnWallet");
const mockedUsePostOnboardingVisible = jest.mocked(usePostOnboardingEntryPointVisibleOnWallet_1.usePostOnboardingEntryPointVisibleOnWallet);
const mockedEntryPointFirstDisplayedDateSelector = jest.mocked(reducer_1.entryPointFirstDisplayedDateSelector);
describe("useAutoDismissPostOnboardingEntryPoint", () => {
beforeAll(() => {
jest.useFakeTimers().setSystemTime(new Date("2020-01-20"));
});
afterAll(() => {
jest.runOnlyPendingTimers();
jest.useRealTimers();
});
beforeEach(() => {
mockedEntryPointFirstDisplayedDateSelector.mockClear();
mockedUsePostOnboardingVisible.mockClear();
mockedDispatch.mockClear();
});
it("should dismiss the entry point if it has been displayed more than 7 days ago", () => {
mockedUsePostOnboardingVisible.mockReturnValue(true);
mockedEntryPointFirstDisplayedDateSelector.mockReturnValue(new Date("2020-01-12"));
(0, react_1.renderHook)(() => (0, useAutoDismissPostOnboardingEntryPoint_1.useAutoDismissPostOnboardingEntryPoint)());
expect(mockedDispatch).toHaveBeenCalledWith({
type: "POST_ONBOARDING_HIDE_WALLET_ENTRY_POINT",
});
});
it("should be true if the entry point has been displayed less than 7 days ago", () => {
mockedUsePostOnboardingVisible.mockReturnValue(true);
mockedEntryPointFirstDisplayedDateSelector.mockReturnValue(new Date("2020-01-14"));
(0, react_1.renderHook)(() => (0, useAutoDismissPostOnboardingEntryPoint_1.useAutoDismissPostOnboardingEntryPoint)());
expect(mockedDispatch).not.toHaveBeenCalled();
});
});
//# sourceMappingURL=useAutoDismissPostOnboardingEntryPoint.test.js.map