Files
mudita-center/libs/core/settings/actions/set-diagnostic-timestamp.action.test.ts
patryk-sierzega c85ceed34c [CP-2260] Setup Nx (#1607)
Co-authored-by: Daniel Karski <daniel.karski5q@gmail.com>
Co-authored-by: Oskar Michalkiewicz <32848134+OskarMichalkiewicz@users.noreply.github.com>
Co-authored-by: Łukasz Kowalczyk <freelancer.lukasz.kowalczyk@gmail.com>
Co-authored-by: Michał Kurczewski <michalkurczewski94@gmail.com>
Co-authored-by: mkurczewski <michal@kurczewski.dev>
2023-12-12 14:40:04 +01:00

44 lines
1.3 KiB
TypeScript

/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
import { AnyAction } from "@reduxjs/toolkit"
import thunk from "redux-thunk"
import createMockStore from "redux-mock-store"
import { setDiagnosticTimestamp } from "./set-diagnostic-timestamp.action"
import { updateSettings } from "Core/settings/requests"
jest.mock("Core/settings/requests", () => ({
updateSettings: jest.fn(),
}))
const dateMock = new Date("2021-08-05T11:50:35.157Z").getDate()
const mockStore = createMockStore([thunk])()
afterEach(() => {
jest.clearAllMocks()
})
test("calls `setDiagnosticTimestamp` and `updateSettings` request with timestamp", async () => {
expect(updateSettings).not.toHaveBeenCalled()
const {
meta: { requestId },
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/await-thenable
} = await mockStore.dispatch(
setDiagnosticTimestamp(dateMock) as unknown as AnyAction
)
expect(mockStore.getActions()).toEqual([
setDiagnosticTimestamp.pending(requestId, dateMock),
setDiagnosticTimestamp.fulfilled(dateMock, requestId, dateMock),
])
expect(updateSettings).toHaveBeenCalledWith({
key: "diagnosticSentTimestamp",
value: dateMock,
})
})