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

38 lines
1.4 KiB
TypeScript

// Copyright (c) 2023 Tudor Stanciu
import { initialDispatchActions } from "../src/initialState";
import { TuitioUserInfo } from "@flare/tuitio-client";
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);
});
it("should have a property `onUserInfoLoaded` that is a function", () => {
expect(initialDispatchActions.onUserInfoLoaded).toBeInstanceOf(Function);
});
it("onLoginSuccess function must return undefined", () => {
const mockToken = "abc123";
const validUntil = new Date("2023-12-31T23:59:59.999Z");
const result = initialDispatchActions.onLoginSuccess(mockToken, validUntil, "user");
expect(result).toBe(undefined);
});
it("onLogoutSuccess function must return undefined", () => {
const result = initialDispatchActions.onLogoutSuccess();
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);
});
});