import { makeAppObjectRepo } from "@vived/core";
import { makeChannelModelRepo } from "../Entities/ChannelModelRepo";
import { makeValidateChannelModel, ValidateChannelModel, } from "./ValidateChannelModel";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const modelRepo = makeChannelModelRepo(appObjects.getOrCreate("repo"));
    const model = modelRepo.createChannelModel();
    const modelObject = model.addModelObject();
    modelRepo.activeModel = model.id;
    const uc = makeValidateChannelModel(appObjects.getOrCreate("ObjectPick"));
    return { modelRepo, uc, registerSpy, appObjects, modelObject };
}
describe("Validate Object Pick UC", () => {
    it("Gets the singleton", () => {
        const { appObjects, uc } = makeTestRig();
        expect(ValidateChannelModel.get(appObjects)).toEqual(uc);
    });
    it("Registers as the singleton", () => {
        const { registerSpy, uc } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(uc);
    });
    it("Returns null if all good", () => {
        const { uc } = makeTestRig();
        expect(uc.validate()).toEqual(null);
    });
    it("If no active mode, return error message.", () => {
        const { uc, modelRepo } = makeTestRig();
        modelRepo.activeModel = "";
        expect(uc.validate()).toEqual(uc.MUST_SELECT_MODEL);
    });
    it("REturns a label validation message", () => {
        const { modelObject, uc } = makeTestRig();
        modelObject.label.customLabelValidator = () => {
            return "Some Error";
        };
        expect(uc.validate()).toEqual("Some Error");
    });
});
//# sourceMappingURL=ValidateChannelModel.test.js.map