"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
const Hideable_1 = require("../../Hideable/Entities/Hideable");
const Entities_1 = require("../Entities");
const UnhideAllChannelModelObjectsUC_1 = require("./UnhideAllChannelModelObjectsUC");
const UnhideAllAppObjectsUndoRedo_1 = require("./UnhideAllAppObjectsUndoRedo");
jest.mock("./UnhideAllAppObjectsUndoRedo");
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, UnhideAllChannelModelObjectsUC_1.makeUnhideAllChannelModelObjectsUC)(ao);
    const dm1 = channelModel.addModelObject("modelId");
    const dm2 = channelModel.addModelObject("modelId");
    const sm1Hideable = Hideable_1.Hideable.addIfMissing(dm1.appObject);
    const sm2Hideable = Hideable_1.Hideable.addIfMissing(dm2.appObject);
    if (sm1Hideable && sm2Hideable) {
        sm1Hideable.isHidden = true;
        sm2Hideable.isHidden = true;
    }
    return {
        uc,
        sm1Hideable,
        sm2Hideable,
        doDispatchMock,
    };
}
describe("uc", () => {
    it("Doesn't submit UnhideAllDissectableMeshesUndoRedo action when hidden dissectable meshes are not found", () => {
        const { uc, sm1Hideable, sm2Hideable } = makeTestRig();
        sm1Hideable.isHidden = false;
        sm2Hideable.isHidden = false;
        uc.unhideAll();
        expect(UnhideAllAppObjectsUndoRedo_1.UnhideAllAppObjectsUndoRedo).not.toHaveBeenCalled();
    });
    it("Unhides all channel model objects", () => {
        const { uc, sm1Hideable, sm2Hideable } = makeTestRig();
        uc.unhideAll();
        expect(sm1Hideable.isHidden).toEqual(false);
        expect(sm2Hideable.isHidden).toEqual(false);
    });
    it("Submits UnhideAllDissociableMeshesUndoRedo action", () => {
        const { uc } = makeTestRig();
        uc.unhideAll();
        expect(UnhideAllAppObjectsUndoRedo_1.UnhideAllAppObjectsUndoRedo).toHaveBeenCalled();
    });
    it("Dispatches state change", () => {
        const { uc, doDispatchMock } = makeTestRig();
        uc.unhideAll();
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Doesn't dispatch state change when hidden dissectable meshes are not found", () => {
        const { uc, sm1Hideable, sm2Hideable, doDispatchMock } = makeTestRig();
        sm1Hideable.isHidden = false;
        sm2Hideable.isHidden = false;
        uc.unhideAll();
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=UnhideAllChannelModelObjectsUC.test.js.map