import { makeAppObjectRepo } from "@vived/core";
import { Color } from "@vived/core";
import { makeThemeColors, ThemeColorType } from "./ThemeColors";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const themeColorsAo = appObjects.getOrCreate("ThemeColors");
    const theme = makeThemeColors(themeColorsAo);
    const observer = jest.fn();
    theme.addChangeObserver(observer);
    return { theme, observer };
}
describe("Theme Colors Entity", () => {
    it("Initialzes the color", () => {
        const { theme } = makeTestRig();
        expect(theme.getColorForType(ThemeColorType.primary)).toEqual(Color.Hex("#00668A"));
        expect(theme.getColorForType(ThemeColorType.onPrimary)).toEqual(Color.Hex("#FFFFFF"));
        expect(theme.getColorForType(ThemeColorType.primaryContainer)).toEqual(Color.Hex("#C4E7FF"));
        expect(theme.getColorForType(ThemeColorType.onPrimaryContainer)).toEqual(Color.Hex("#001E2C"));
        expect(theme.getColorForType(ThemeColorType.primaryFixed)).toEqual(Color.Hex("#C4E7FF"));
        expect(theme.getColorForType(ThemeColorType.onPrimaryFixed)).toEqual(Color.Hex("#001E2C"));
        expect(theme.getColorForType(ThemeColorType.primaryFixedDim)).toEqual(Color.Hex("#7BD0FF"));
        expect(theme.getColorForType(ThemeColorType.onPrimaryFixedVariant)).toEqual(Color.Hex("#004C69"));
        expect(theme.getColorForType(ThemeColorType.secondary)).toEqual(Color.Hex("#4E616D"));
        expect(theme.getColorForType(ThemeColorType.onSecondary)).toEqual(Color.Hex("#FFFFFF"));
        expect(theme.getColorForType(ThemeColorType.secondaryContainer)).toEqual(Color.Hex("#D1E5F4"));
        expect(theme.getColorForType(ThemeColorType.onSecondaryContainer)).toEqual(Color.Hex("#0A1E28"));
        expect(theme.getColorForType(ThemeColorType.onSecondaryFixed)).toEqual(Color.Hex("#0A1E28"));
        expect(theme.getColorForType(ThemeColorType.secondaryFixedDim)).toEqual(Color.Hex("#B5C9D7"));
        expect(theme.getColorForType(ThemeColorType.onSecondaryFixedVariant)).toEqual(Color.Hex("#374955"));
        expect(theme.getColorForType(ThemeColorType.tertiary)).toEqual(Color.Hex("#605A7D"));
        expect(theme.getColorForType(ThemeColorType.onTertiary)).toEqual(Color.Hex("#FFFFFF"));
        expect(theme.getColorForType(ThemeColorType.tertiaryContainer)).toEqual(Color.Hex("#E6DEFF"));
        expect(theme.getColorForType(ThemeColorType.onTertiaryContainer)).toEqual(Color.Hex("#1D1736"));
        expect(theme.getColorForType(ThemeColorType.tertiaryFixed)).toEqual(Color.Hex("#E6DEFF"));
        expect(theme.getColorForType(ThemeColorType.onTertiaryFixed)).toEqual(Color.Hex("#1D1736"));
        expect(theme.getColorForType(ThemeColorType.tertiaryFixedDim)).toEqual(Color.Hex("#CAC1E9"));
        expect(theme.getColorForType(ThemeColorType.onTertiaryFixedVariant)).toEqual(Color.Hex("#484264"));
        expect(theme.getColorForType(ThemeColorType.error)).toEqual(Color.Hex("#BA1A1A"));
        expect(theme.getColorForType(ThemeColorType.onError)).toEqual(Color.Hex("#FFFFFF"));
        expect(theme.getColorForType(ThemeColorType.errorContainer)).toEqual(Color.Hex("#FFDAD6"));
        expect(theme.getColorForType(ThemeColorType.onErrorContainer)).toEqual(Color.Hex("#410002"));
        expect(theme.getColorForType(ThemeColorType.outline)).toEqual(Color.Hex("#71787D"));
        expect(theme.getColorForType(ThemeColorType.background)).toEqual(Color.Hex("#FBFCFF"));
        expect(theme.getColorForType(ThemeColorType.onBackground)).toEqual(Color.Hex("#191C1E"));
        expect(theme.getColorForType(ThemeColorType.surface)).toEqual(Color.Hex("#F8F9FC"));
        expect(theme.getColorForType(ThemeColorType.onSurface)).toEqual(Color.Hex("#191C1E"));
        expect(theme.getColorForType(ThemeColorType.surfaceVariant)).toEqual(Color.Hex("#DCE3E9"));
        expect(theme.getColorForType(ThemeColorType.onSurfaceVariant)).toEqual(Color.Hex("#41484D"));
        expect(theme.getColorForType(ThemeColorType.inverseSurface)).toEqual(Color.Hex("#2E3133"));
        expect(theme.getColorForType(ThemeColorType.inverseOnSurface)).toEqual(Color.Hex("#F0F1F3"));
        expect(theme.getColorForType(ThemeColorType.inversePrimary)).toEqual(Color.Hex("#7BD0FF"));
        expect(theme.getColorForType(ThemeColorType.shadow)).toEqual(Color.Hex("#000000"));
        expect(theme.getColorForType(ThemeColorType.surfaceTint)).toEqual(Color.Hex("#00668A"));
        expect(theme.getColorForType(ThemeColorType.outlineVariant)).toEqual(Color.Hex("#C0C7CD"));
        expect(theme.getColorForType(ThemeColorType.scrim)).toEqual(Color.Hex("#000000"));
        expect(theme.getColorForType(ThemeColorType.surfaceContainerHighest)).toEqual(Color.Hex("#E1E2E5"));
        expect(theme.getColorForType(ThemeColorType.surfaceContainerHigh)).toEqual(Color.Hex("#E7E8EA"));
        expect(theme.getColorForType(ThemeColorType.surfaceContainer)).toEqual(Color.Hex("#EDEEF0"));
        expect(theme.getColorForType(ThemeColorType.surfaceContainerLow)).toEqual(Color.Hex("#F3F3F6"));
        expect(theme.getColorForType(ThemeColorType.surfaceContainerLowest)).toEqual(Color.Hex("#FFFFFF"));
        expect(theme.getColorForType(ThemeColorType.surfaceBright)).toEqual(Color.Hex("#F8F9FC"));
        expect(theme.getColorForType(ThemeColorType.surfaceDim)).toEqual(Color.Hex("#D9DADC"));
    });
    it("Sets the color for a type and notifies", () => {
        const { theme, observer } = makeTestRig();
        const c = Color.RGB(10, 20, 30);
        theme.setColorForType(ThemeColorType.onBackground, c);
        theme.setColorForType(ThemeColorType.onBackground, c);
        theme.setColorForType(ThemeColorType.onBackground, c);
        theme.setColorForType(ThemeColorType.onBackground, c);
        expect(observer).toHaveBeenCalledTimes(1);
        expect(theme.getColorForType(ThemeColorType.onBackground)).toEqual(c);
    });
    it("Sets the color by hex for a type and notifies", () => {
        const { theme, observer } = makeTestRig();
        theme.setColorHexForType(ThemeColorType.onBackground, "#00668a");
        theme.setColorHexForType(ThemeColorType.onBackground, "#00668a");
        theme.setColorHexForType(ThemeColorType.onBackground, "#00668a");
        theme.setColorHexForType(ThemeColorType.onBackground, "#00668a");
        expect(observer).toHaveBeenCalledTimes(1);
        expect(theme.getColorForType(ThemeColorType.onBackground).hex).toEqual("#00668a");
    });
    it("Sets the colors by hex for a set of colors and notifies", () => {
        const { theme, observer } = makeTestRig();
        const colorSet = new Map();
        colorSet.set(ThemeColorType.onBackground, "00668a");
        colorSet.set(ThemeColorType.onPrimary, "00668b");
        colorSet.set(ThemeColorType.onPrimaryContainer, "00668c");
        colorSet.set(ThemeColorType.onPrimaryFixedVariant, "00668d");
        theme.setColorHexForSet(colorSet);
        expect(observer).toHaveBeenCalledTimes(4);
        expect(theme.getColorForType(ThemeColorType.onBackground).hex).toEqual("#00668a");
        expect(theme.getColorForType(ThemeColorType.onPrimary).hex).toEqual("#00668b");
        expect(theme.getColorForType(ThemeColorType.onPrimaryContainer).hex).toEqual("#00668c");
        expect(theme.getColorForType(ThemeColorType.onPrimaryFixedVariant).hex).toEqual("#00668d");
    });
});
//# sourceMappingURL=ThemeColors.test.js.map