// (C) 2019 GoodData Corporation import { createDateFilterDashboardConfig, createDateFiltersConfigBody } from "../DateFilterConfigBuilder"; import { schema } from "../../fixtures/dummySchema"; import { createProject } from "../ProjectBuilder"; describe("createDateFilterDashboardConfig", () => { it("should build configuration", () => { const expected = { filterName: "Date range", mode: "active", hideOptions: ["foo", "bar"], addPresets: { absolutePresets: [ { from: "2019-01-01", localIdentifier: "baz", name: "Baz", to: "2019-01-31", visible: true, }, ], }, hideGranularities: ["GDC.time.date"], }; const actual = createDateFilterDashboardConfig({ filterName: "Date range", mode: "active", hideOptions: ["foo", "bar"], addPresets: { absolutePresets: [ { from: "2019-01-01", localIdentifier: "baz", name: "Baz", to: "2019-01-31", visible: true, }, ], }, hideGranularities: ["GDC.time.date"], }); expect(actual).toEqual(expected); }); }); describe("createDateFiltersConfigBody", () => { it("should build configuration", () => { const expected = { content: { absoluteForm: { localIdentifier: "absoluteFormIdentifier", name: "testName", visible: true, }, absolutePresets: [ { from: "2017-01-01", localIdentifier: "my_identifier_absolute", name: "my_name2", to: "2018-01-01", visible: true, }, ], allTime: { localIdentifier: "allTimeIdentifier", name: "testName", visible: true, }, relativeForm: { granularities: ["GDC.time.date", "GDC.time.year"], localIdentifier: "relativeFormIdentifier", name: "testName", visible: true, }, relativePresets: [ { from: 1, granularity: "GDC.time.year", localIdentifier: "my_identifier_relative", name: "my_name", to: 2, visible: true, }, ], selectedOption: "allTimeIdentifier", }, meta: { category: "dateFilterConfig", identifier: "defaultDateFilterConfig", title: "Date filter", uri: "/gdc/md/mockproject/obj/defaultDateFilterConfig", }, }; const actual = createDateFiltersConfigBody(createProject(schema), schema.dateFilterConfig); expect(actual).toEqual(expected); }); });