import { makeAppObjectRepo } from "@vived/core";
import { ToolPMMock } from "../Mocks/ToolPMMock";
import { defaultToolVM } from "../PM/ToolPM";
import { toolAdapter } from "./toolAdapter";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("id");
    const mockPM = new ToolPMMock(ao);
    return { appObjects, mockPM };
}
describe("Tool Adapter", () => {
    it("Sets the Default VM", () => {
        expect(toolAdapter.defaultVM).toEqual(defaultToolVM);
    });
    it("Add a view on subscribe", () => {
        const { mockPM, appObjects } = makeTestRig();
        mockPM.addView = jest.fn();
        const setVM = jest.fn();
        toolAdapter.subscribe("id", appObjects, setVM);
        expect(mockPM.addView).toHaveBeenCalledWith(setVM);
    });
    it("Removes a view on unsubscribe", () => {
        const { mockPM, appObjects } = makeTestRig();
        mockPM.removeView = jest.fn();
        const setVM = jest.fn();
        toolAdapter.unsubscribe("id", appObjects, setVM);
        expect(mockPM.removeView).toHaveBeenCalledWith(setVM);
    });
});
//# sourceMappingURL=toolAdapter.test.js.map