import { makeAppObjectRepo } from "@vived/core";
import { selectableStateAdapter } from "./selectableStateAdapter";
import { SelectableStatePMMock } from "../Mocks/SelectableStatePMMock";
import { defaultSelectableStateVM } from "../PM/SelectableStatePM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const ao = appObjects.getOrCreate("id");
    const mockPM = new SelectableStatePMMock(ao);
    return { appObjects, mockPM };
}
describe("Selectable State Adapter", () => {
    it("Sets the Default VM", () => {
        expect(selectableStateAdapter.defaultVM).toEqual(defaultSelectableStateVM);
    });
    it("Add a view on subscribe", () => {
        const { mockPM, appObjects } = makeTestRig();
        mockPM.addView = jest.fn();
        const setVM = jest.fn();
        selectableStateAdapter.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();
        selectableStateAdapter.unsubscribe("id", appObjects, setVM);
        expect(mockPM.removeView).toHaveBeenCalledWith(setVM);
    });
});
//# sourceMappingURL=selectableStateAdapter.test.js.map