"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const Entities_1 = require("../Entities");
const ThemeColorMapPM_1 = require("./ThemeColorMapPM");
function setupThemeColors(appObjects) {
    const themeColorsAo = appObjects.getOrCreate("ThemeColors");
    return (0, Entities_1.makeThemeColors)(themeColorsAo);
}
function makeTestRig() {
    const entites = (0, core_1.makeAppObjectRepo)();
    const themeColors = setupThemeColors(entites);
    const view = jest.fn();
    const pm = new ThemeColorMapPM_1.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(Entities_1.ThemeColorType.onError, core_2.Color.Hex("#1cfc03"));
        expect(view).toHaveBeenCalledTimes(1);
        const lookup = view.mock.calls[0][0];
        expect(lookup.get(Entities_1.ThemeColorType.onError)?.hex).toEqual("#1cfc03");
    });
    it("It can be disposed", () => {
        const { view, themeColors, pm } = makeTestRig();
        view.mockClear();
        pm.dispose();
        themeColors.setColorForType(Entities_1.ThemeColorType.onError, core_2.Color.Hex("#1cfc03"));
        expect(view).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ThemeColorMapPM.test.js.map