import * as salesforceWebchatHelperdev from "./salesforce-helper-dev";
import * as salesforceWebchatHelperqa from "./salesforce-helper-qa";
import * as salesforceWebchatHelperprod from "./salesforce-helper-prod";

const mockEmbeddedSvc = {
    settings: {},
    init: jest.fn(),
    testFlag: true,
};

describe("Salesforce Webchat Helper Tests", () => {
    describe("Files and exposed methods exist", () => {
        it("exposes initialization methods", () => {
            expect(typeof salesforceWebchatHelperdev.initializeSalesforceWebchatForDev).toBe(
                "function"
            );
            expect(typeof salesforceWebchatHelperqa.initializeSalesforceWebchatForQa).toBe(
                "function"
            );
            expect(typeof salesforceWebchatHelperprod.initializeSalesforceWebchatForProd).toBe(
                "function"
            );
        });
    }),
        describe("Custom code added correctly", () => {
            it("defines a local variable 'embedded_svc' in the initESW method", () => {
                mockEmbeddedSvc.testFlag = "dev";
                window.embedded_svc = mockEmbeddedSvc;
                salesforceWebchatHelperdev.initializeSalesforceWebchatForDev();
                expect(embedded_svc.testFlag).toBe("dev");

                mockEmbeddedSvc.testFlag = "qa";
                window.embedded_svc = mockEmbeddedSvc;
                salesforceWebchatHelperqa.initializeSalesforceWebchatForQa();
                expect(embedded_svc.testFlag).toBe("qa");

                mockEmbeddedSvc.testFlag = "prod";
                window.embedded_svc = mockEmbeddedSvc;
                salesforceWebchatHelperprod.initializeSalesforceWebchatForProd();
                expect(embedded_svc.testFlag).toBe("prod");
            });
        });
});
