import ModelCatalogReducer from "../ModelCatalogReducer";
import { DateUtil } from "../../../utils";
import { INCLUDE_TIME_OFFSET, setSettings } from "../../../constants";

describe("modelcatalog reducer", () => {
  it("should return the initial state", () => {
    setSettings({ [INCLUDE_TIME_OFFSET]: false });

    expect(ModelCatalogReducer(undefined, {})).toStrictEqual({
      entryDate: DateUtil.now(),
    });
    expect(ModelCatalogReducer()).toStrictEqual({ entryDate: DateUtil.now() });
  });

  it("should handle UPDATE_ENTRYDATE", () => {
    expect(
      ModelCatalogReducer(undefined, {
        type: "UPDATE_ENTRYDATE",
        payload: "2024-01-01",
      }),
    ).toStrictEqual({ entryDate: "2024-01-01" });
  });
});
