// (C) 2019 GoodData Corporation import { simpleMeasure, simpleMeasureWithFormat, simpleMeasureWithIdentifiers, simpleMeasureWithTextFilter, renamedMeasure, filteredMeasure, measureWithAbsoluteDate, measureWithRelativeDate, popMeasure, showInPercent, showInPercentWithDate, measureWithSorting, factBasedMeasure, factBasedRenamedMeasure, attributeBasedMeasure, attributeBasedRenamedMeasure, stackingAttribute, stackingRenamedAttribute, attributeFilter, attributeTextFilter, attributeFilterWithAll, dateFilter, dateFilterWithoutInterval, oneMeasureOneAttribute, oneMeasureOneAttributeWithIdentifiers, nativeSubTotals, nativeSubtotalsInTwoDimensions, } from "./fixtures/Afm.fixtures"; import { charts, tables } from "./fixtures/VisObj.fixtures"; import { toAfm } from "../toAfm"; describe("toAfm", () => { it("should convert simple measures", () => { expect(toAfm(charts.simpleMeasure)).toEqual({ ...simpleMeasure, }); }); it("should convert simple measures with identifiers", () => { expect(toAfm(charts.simpleMeasureWithIdentifiers)).toEqual({ ...simpleMeasureWithIdentifiers, }); }); it("should convert simple measure with format", () => { expect(toAfm(charts.simpleMeasureWithFormat)).toEqual({ ...simpleMeasureWithFormat, }); }); it("should convert simple measure with text filter", () => { expect(toAfm(charts.simpleMeasureWithTextFilter)).toEqual({ ...simpleMeasureWithTextFilter, }); }); it("should convert simple renamed measures", () => { expect(toAfm(charts.renamedMeasure)).toEqual({ ...renamedMeasure, }); }); it("should convert filtered measures", () => { expect(toAfm(charts.filteredMeasure)).toEqual({ ...filteredMeasure, }); }); it("should convert relative date filtered measures", () => { expect(toAfm(charts.measureWithRelativeDate)).toEqual({ ...measureWithRelativeDate, }); }); it("should convert absolute date filtered measures", () => { expect(toAfm(charts.measureWithAbsoluteDate)).toEqual({ ...measureWithAbsoluteDate, }); }); it("should convert fact based measures", () => { expect(toAfm(charts.factBasedMeasure)).toEqual({ ...factBasedMeasure, }); }); it("should convert fact based renamed measures", () => { expect(toAfm(charts.factBasedRenamedMeasure)).toEqual({ ...factBasedRenamedMeasure, }); }); it("should convert attribute based measures", () => { expect(toAfm(charts.attributeBasedMeasure)).toEqual({ ...attributeBasedMeasure, }); }); it("should convert attribute based measures and add its default format #,##0", () => { expect(toAfm(charts.attributeBasedMeasureWithoutFormat)).toEqual({ ...attributeBasedMeasure, }); }); it("should convert attribute based renamed measures", () => { expect(toAfm(charts.attributeBasedRenamedMeasure)).toEqual({ ...attributeBasedRenamedMeasure, }); }); it("should convert measure with show in percent with attribute", () => { expect(toAfm(charts.showInPercent)).toEqual({ ...showInPercent, }); }); it("should convert measure with show in percent and add its default format #,##0.00%", () => { expect(toAfm(charts.showInPercentWithoutFormat)).toEqual({ ...showInPercent, }); }); it("should convert measure with show in percent with date", () => { expect(toAfm(charts.showInPercentWithDate)).toEqual({ ...showInPercentWithDate, }); }); it("should convert measure with sorting", () => { expect(toAfm(charts.measureWithSorting)).toEqual({ ...measureWithSorting, }); }); it("should convert pop measure", () => { expect(toAfm(charts.popMeasure)).toEqual({ ...popMeasure, }); }); it("should convert attribute filter", () => { expect(toAfm(charts.attributeFilter)).toEqual({ ...attributeFilter, }); }); it("should convert attribute filter", () => { expect(toAfm(charts.attributeTextFilter)).toEqual({ ...attributeTextFilter, }); }); it("should convert date filter", () => { expect(toAfm(charts.dateFilter)).toEqual({ ...dateFilter, }); }); it("should convert date filter with from/to as strings", () => { expect(toAfm(charts.dateFilterWithStrings)).toEqual({ ...dateFilter, }); }); it("should skip filter when date filter from/to is undefined for relative (alltime)", () => { expect(toAfm(charts.dateFilterWithUndefs)).toEqual({ ...dateFilterWithoutInterval, }); }); it("should convert stacking renamed attribute", () => { expect(toAfm(charts.stackingRenamedAttribute)).toEqual({ ...stackingRenamedAttribute, }); }); it("should skip attribute filter with ALL", () => { expect(toAfm(charts.attributeFilterWithAll)).toEqual({ ...attributeFilterWithAll, }); }); it("should convert stacking attribute as normal attribute, conversion has no semantic for buckets", () => { expect(toAfm(charts.stackingAttribute)).toEqual({ ...stackingAttribute, }); }); it("should convert table as generic chart, conversion has no semantic for buckets", () => { expect(toAfm(tables.oneMeasureOneAttribute)).toEqual({ ...oneMeasureOneAttribute, }); }); it("should convert table with identifiers", () => { expect(toAfm(tables.oneMeasureOneAttributeWithIdentifiers)).toEqual({ ...oneMeasureOneAttributeWithIdentifiers, }); }); it("should convert native subtotals", () => { expect(toAfm(tables.twoAttributesAndNativeSubtotals)).toEqual(nativeSubTotals); }); it("should convert native subtotals from multiple dimensions", () => { expect(toAfm(tables.twoDimensionsAndNativeSubtotals)).toEqual(nativeSubtotalsInTwoDimensions); }); });