import { makeAppObjectRepo } from "@vived/core";
import { makeBaseAppState } from "../../BaseApp/Entity/BaseAppState";
import { makeObjectPickEntity } from "../Entities/ObjectPickEntity";
import { makeValidateObjectPickUC, ValidateObjectPickUC, } from "./ValidateObjectPickUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const baseApp = makeBaseAppState(appObjects.getOrCreate("App"));
    const objectPick = makeObjectPickEntity(appObjects.getOrCreate("ObjectPick"));
    const uc = makeValidateObjectPickUC(appObjects.getOrCreate("ObjectPick"));
    return { objectPick, uc, baseApp, registerSpy, appObjects };
}
describe("Validate Object Pick UC", () => {
    it("Gets the singleton", () => {
        const { appObjects, uc } = makeTestRig();
        expect(ValidateObjectPickUC.get(appObjects)).toEqual(uc);
    });
    it("Registers as the singleton", () => {
        const { registerSpy, uc } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(uc);
    });
    it("If object pick is within parameters returns null", () => {
        const { baseApp, objectPick, uc } = makeTestRig();
        baseApp.slideText = "Slide Text";
        objectPick.addCorrectObjectId("someID");
        expect(uc.validateObjectPick()).toBe(null);
    });
    it("If slide text is empty, return error message.", () => {
        const { baseApp, uc } = makeTestRig();
        baseApp.slideText = "";
        expect(uc.validateObjectPick()).toBe(uc.OBJECT_PICK_CHALLENGE_NO_SLIDE_TEXT);
    });
    it("If object pick equals zero, then return error message.", () => {
        const { baseApp, objectPick, uc } = makeTestRig();
        baseApp.slideText = "Slide Text";
        objectPick.clearCorrectObjectIds();
        expect(uc.validateObjectPick()).toBe(uc.OBJECT_PICK_ENTITY_SHOULD_HAVE_AT_LEAST_ONE_ID);
    });
});
//# sourceMappingURL=ValidateObjectPickUC.test.js.map