import { makeAppObjectRepo } from "@vived/core";
import { makeToolEntity, ToolState } from "../Entities/ToolEntity";
import { makeToolPM } from "./ToolPM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const toolAO = appObjects.getOrCreate("tool");
    const tool = makeToolEntity(toolAO);
    const pm = makeToolPM(toolAO);
    const view = jest.fn();
    pm.addView(view);
    return { view, pm, tool };
}
describe("Tool Presentation Manager", () => {
    it("Initializes the view", () => {
        const { pm, tool } = makeTestRig();
        const vm = pm.lastVM;
        expect(vm.label).toEqual(tool.label);
        expect(vm.shortcutLabel).toEqual(tool.shortcutLabel);
        expect(vm.tooltipLabel).toEqual(`${tool.label} [${tool.shortcutLabel}]`);
    });
    it("Sets the enabled flag true when enabled", () => {
        const { pm, tool } = makeTestRig();
        expect(tool.state).toEqual(ToolState.ENABLED);
        const vm = pm.lastVM;
        expect(vm.enabled).toEqual(true);
    });
    it("Sets the enabled flag true when active", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.ACTIVE;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.enabled).toEqual(true);
    });
    it("Sets the enabled flag false when disabled", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.DISABLED;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.enabled).toEqual(false);
    });
    it("Sets the enabled flag false when hidden", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.HIDDEN;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.enabled).toEqual(false);
    });
    it("Sets the selected flag false when enabled", () => {
        const { view, tool } = makeTestRig();
        expect(view).toHaveBeenCalled();
        expect(tool.state).toEqual(ToolState.ENABLED);
        const vm = view.mock.calls[0][0];
        expect(vm.selected).toEqual(false);
    });
    it("Sets the selected flag true when active", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.ACTIVE;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.selected).toEqual(true);
    });
    it("Sets the selected flag false when disabled", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.DISABLED;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.selected).toEqual(false);
    });
    it("Sets the selected flag false when hidden", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.HIDDEN;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.selected).toEqual(false);
    });
    it("Sets the shown flag true when enabled", () => {
        const { view, tool } = makeTestRig();
        expect(view).toHaveBeenCalled();
        expect(tool.state).toEqual(ToolState.ENABLED);
        const vm = view.mock.calls[0][0];
        expect(vm.show).toEqual(true);
    });
    it("Sets the show flag true when active", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.ACTIVE;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.show).toEqual(true);
    });
    it("Sets the show flag true when disabled", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.DISABLED;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.show).toEqual(true);
    });
    it("Sets the show flag false when hidden", () => {
        const { view, tool } = makeTestRig();
        view.mockClear();
        tool.state = ToolState.HIDDEN;
        expect(view).toHaveBeenCalled();
        const vm = view.mock.calls[0][0];
        expect(vm.show).toEqual(false);
    });
    it("Can be disposed", () => {
        const { view, tool, pm } = makeTestRig();
        view.mockClear();
        pm.dispose();
        tool.state = ToolState.HIDDEN;
        expect(view).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ToolPM.test.js.map