import { makeAppObjectRepo } from "@vived/core";
import { Color } from "@vived/core";
import { ThemeColorType, makeThemeColors } from "../Entities";
import { ThemeColorMapPM } from "./ThemeColorMapPM";
function setupThemeColors(appObjects) {
    const themeColorsAo = appObjects.getOrCreate("ThemeColors");
    return makeThemeColors(themeColorsAo);
}
function makeTestRig() {
    const entites = makeAppObjectRepo();
    const themeColors = setupThemeColors(entites);
    const view = jest.fn();
    const pm = new ThemeColorMapPM(themeColors.appObject);
    pm.addView(view);
    return { ...entites, themeColors, view, pm };
}
describe("Theme Color Map PM", () => {
    it("Initializes the view", () => {
        const { view } = makeTestRig();
        expect(view).toHaveBeenCalledTimes(1);
    });
    it("Updates the view when the color changes", () => {
        const { view, themeColors } = makeTestRig();
        view.mockClear();
        themeColors.setColorForType(ThemeColorType.onError, Color.Hex("#1cfc03"));
        expect(view).toHaveBeenCalledTimes(1);
        const lookup = view.mock.calls[0][0];
        expect(lookup.get(ThemeColorType.onError)?.hex).toEqual("#1cfc03");
    });
    it("It can be disposed", () => {
        const { view, themeColors, pm } = makeTestRig();
        view.mockClear();
        pm.dispose();
        themeColors.setColorForType(ThemeColorType.onError, Color.Hex("#1cfc03"));
        expect(view).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ThemeColorMapPM.test.js.map