"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
const OverlayColor_1 = require("../../OverlayColor/Entities/OverlayColor");
const Entities_1 = require("../Entities");
const ClearAllColorOverlayUndoRedo_1 = require("./ClearAllColorOverlayUndoRedo");
const ClearModelObjectOverlaysUC_1 = require("./ClearModelObjectOverlaysUC");
jest.mock("./ClearAllColorOverlayUndoRedo");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const mockDispatchStateChange = (0, MockDispatchStateChange_1.makeMockDispatchStateChange)(appObjects);
    const doDispatchMock = jest.fn();
    mockDispatchStateChange.doDispatch = doDispatchMock;
    const ao = appObjects.getOrCreate("ChannelModel");
    const channelModel = (0, Entities_1.makeChannelModelEntity)(ao);
    const uc = (0, ClearModelObjectOverlaysUC_1.makeClearModelObjectOverlaysUC)(ao);
    const model1 = channelModel.addModelObject("model1");
    const model2 = channelModel.addModelObject("model2");
    const overlay1 = new OverlayColor_1.OverlayColor(model1.appObject);
    const overlay2 = new OverlayColor_1.OverlayColor(model2.appObject);
    overlay1.overlayColor = OverlayColor_1.OverlayColorEnums.BLACK;
    overlay2.overlayColor = OverlayColor_1.OverlayColorEnums.BLUE;
    return {
        uc,
        overlay1,
        overlay2,
        mockDispatchStateChange,
        doDispatchMock,
    };
}
describe("uc", () => {
    it("Doesn't submit UnhideAllDissectableMeshesUndoRedo action when hidden dissectable meshes are not found", () => {
        const { uc, overlay1, overlay2 } = makeTestRig();
        overlay1.overlayColor = OverlayColor_1.OverlayColorEnums.NONE;
        overlay2.overlayColor = OverlayColor_1.OverlayColorEnums.NONE;
        uc.clearOverlays();
        expect(ClearAllColorOverlayUndoRedo_1.ClearAllColorOverlayUndoRedo).not.toHaveBeenCalled();
    });
    it("Clears all the overlays", () => {
        const { uc, overlay1, overlay2 } = makeTestRig();
        uc.clearOverlays();
        expect(overlay1.overlayColor).toEqual(OverlayColor_1.OverlayColorEnums.NONE);
        expect(overlay2.overlayColor).toEqual(OverlayColor_1.OverlayColorEnums.NONE);
    });
    it("Submits UnhideAllDissectableMeshesUndoRedo action", () => {
        const { uc } = makeTestRig();
        uc.clearOverlays();
        expect(ClearAllColorOverlayUndoRedo_1.ClearAllColorOverlayUndoRedo).toHaveBeenCalled();
    });
    it("Dispatches state change", () => {
        const { uc, doDispatchMock } = makeTestRig();
        uc.clearOverlays();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Doesn't dispatch state change when hidden dissectable meshes are not found", () => {
        const { uc, overlay1, overlay2, doDispatchMock } = makeTestRig();
        overlay1.overlayColor = OverlayColor_1.OverlayColorEnums.NONE;
        overlay2.overlayColor = OverlayColor_1.OverlayColorEnums.NONE;
        uc.clearOverlays();
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ClearModelObjectOverlaysUC.test.js.map