tuitio-client-react/tests/initialState.test.ts

38 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-03-18 15:54:29 +02:00
// Copyright (c) 2023 Tudor Stanciu
2023-02-11 21:44:41 +02:00
import { initialDispatchActions } from "../src/initialState";
import { TuitioUserInfo } from "@flare/tuitio-client";
2023-02-11 21:44:41 +02:00
describe("Initial dispatch actions", () => {
it("should have a property `onLoginSuccess` that is a function", () => {
expect(initialDispatchActions.onLoginSuccess).toBeInstanceOf(Function);
});
it("should have a property `onLogoutSuccess` that is a function", () => {
expect(initialDispatchActions.onLogoutSuccess).toBeInstanceOf(Function);
2023-02-11 21:44:41 +02:00
});
it("should have a property `onUserInfoLoaded` that is a function", () => {
expect(initialDispatchActions.onUserInfoLoaded).toBeInstanceOf(Function);
});
2023-02-11 21:44:41 +02:00
it("onLoginSuccess function must return undefined", () => {
const mockToken = "abc123";
const validUntil = new Date("2023-12-31T23:59:59.999Z");
2023-02-11 21:44:41 +02:00
const result = initialDispatchActions.onLoginSuccess(mockToken, validUntil, "user");
2023-02-11 21:44:41 +02:00
expect(result).toBe(undefined);
});
it("onLogoutSuccess function must return undefined", () => {
const result = initialDispatchActions.onLogoutSuccess();
2023-02-11 21:44:41 +02:00
expect(result).toBe(undefined);
});
it("onUserInfoLoaded function must return undefined", () => {
const userInfoMock: jest.Mocked<TuitioUserInfo> = {} as jest.Mocked<TuitioUserInfo>;
const result = initialDispatchActions.onUserInfoLoaded(userInfoMock);
expect(result).toBe(undefined);
});
2023-02-11 21:44:41 +02:00
});