mirror of
https://github.com/mudita/mudita-center.git
synced 2025-12-23 22:28:03 -05:00
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>
44 lines
1.3 KiB
TypeScript
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,
|
|
})
|
|
})
|