// (C) 2019-2020 GoodData Corporation import { createDrillDefinitions } from "../DrillDefinitionBuilder"; import { createProject } from "../ProjectBuilder"; import { schema } from "../../fixtures/dummySchema"; import { ISchemaDrillToVisualization, ISchemaDrillToDashboard, ISchemaDrillToCustomUrl, ISchemaDrillToAttributeUrl, } from "../../model/SchemaDrillDefinition"; describe("DrillDefinitionBuilder", () => { it("should return undefined when Drill not defined", () => { const project = createProject(schema); expect(createDrillDefinitions(undefined, project)).toEqual(undefined); }); it("should return correct drillToVisualization ", () => { const project = createProject(schema); const drillToVisualizationSchema: ISchemaDrillToVisualization[] = [ { drillToVisualization: { target: "pop-up", from: "bbb", toVisualization: "sss", }, }, ]; expect(createDrillDefinitions(drillToVisualizationSchema, project)).toMatchSnapshot(); }); it("should return correct drillToDashboard ", () => { const project = createProject(schema); const drillToDashboardSchema: ISchemaDrillToDashboard[] = [ { drillToDashboard: { target: "in-place", from: "bbb", toDashboard: "sss", }, }, ]; expect(createDrillDefinitions(drillToDashboardSchema, project)).toMatchSnapshot(); }); it("should return correct drillToCustomUrl ", () => { const project = createProject(schema); const drillToCustomUrlSchema: ISchemaDrillToCustomUrl[] = [ { drillToCustomUrl: { target: "new-window", from: "bbb", customUrl: "https://google.com", }, }, ]; expect(createDrillDefinitions(drillToCustomUrlSchema, project)).toMatchSnapshot(); }); it("should return correct drillToAttributeUrl ", () => { const project = createProject(schema); const drillToAttributeUrlSchema: ISchemaDrillToAttributeUrl[] = [ { drillToAttributeUrl: { target: "new-window", from: "bbb", insightAttributeDisplayForm: "/mockproject/obj/1", drillToAttributeDisplayForm: "/mockproject/obj/2", }, }, ]; expect(createDrillDefinitions(drillToAttributeUrlSchema, project)).toMatchSnapshot(); }); });