/**
 * @jest-environment jsdom
 */
import PatientMgmt from "."
import CfCore from "../../core/CfCore";
import { ContentBlock } from "../Navigation/typings";
import { ProfileAction, ProfileListType, ProfileType, SocialTypes } from "./typings";

let windowSpy
let mockSender;
let mockImpressionManager

describe('ELearning', () => {
    beforeAll(() => {
        mockSender = {
            add() { return false }
        }
    })

    beforeEach(() => {
        windowSpy = jest.spyOn(window, "window", "get");
    })

    afterEach(() => {
        // to remove the singleton instance
        (CfCore as any).instance = null
    })

    it('Should deliver a "Profile" event', () => {
        const senderSpy = jest.spyOn(mockSender, 'add')
        const bsCore = CfCore.createInstance(mockSender as any, mockImpressionManager as any, false, ContentBlock.Core,'device-id', false)

        const event = {
            type: ProfileType.User,
            action: ProfileAction.View,
            profile_id: '123',
        }

        // PatientMgmt.logProfileEvent(event)

        expect(senderSpy).toBeCalledWith(
            expect.anything(),
            expect.anything(),
            expect.objectContaining(
            {
                type: SocialTypes.Profile,
                props: event
            }),
            expect.anything())
    })

    it('Should deliver a "ProfileList" event', () => {
        const senderSpy = jest.spyOn(mockSender, 'add')
        const bsCore = CfCore.createInstance(mockSender as any, mockImpressionManager as any, false,ContentBlock.Core, 'device-id', false)

        const event = {
            type: ProfileListType.Followers,
        }

        // PatientMgmt.logProfileListEvent(event)

        expect(senderSpy).toBeCalledWith(
            expect.anything(),
            expect.anything(),expect.objectContaining(
            {
                type: SocialTypes.ProfileList,
                props: event
            }),
            expect.anything())
    })


})
