diff --git a/lib/index.d.ts b/lib/index.d.ts index 2bef555..2cc3dd7 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -7,6 +7,8 @@ declare module powerbi.extensibility.utils.dataview { module DataViewTransform { function createValueColumns(values?: DataViewValueColumn[], valueIdentityFields?: ISQExpr[], source?: DataViewMetadataColumn): DataViewValueColumns; function setGrouped(values: DataViewValueColumns, groupedResult?: DataViewValueColumnGroup[]): void; + /** Group together the values with a common identity. */ + function groupValues(values: DataViewValueColumn[]): DataViewValueColumnGroup[]; } } declare module powerbi.extensibility.utils.dataview { @@ -24,8 +26,14 @@ declare module powerbi.extensibility.utils.dataview { } } declare module powerbi.extensibility.utils.dataview { - import DataViewObjects = powerbi.DataViewObjects; - import DataViewObjectPropertyIdentifier = powerbi.DataViewObjectPropertyIdentifier; + import IDataViewObject = powerbi.DataViewObject; + module DataViewObject { + function getValue(object: IDataViewObject, propertyName: string, defaultValue?: T): T; + /** Gets the solid color from a fill property using only a propertyName */ + function getFillColorByPropertyName(object: IDataViewObject, propertyName: string, defaultColor?: string): string; + } +} +declare module powerbi.extensibility.utils.dataview { import IDataViewObject = powerbi.DataViewObject; module DataViewObjects { /** Gets the value of the given object/property pair. */ @@ -36,22 +44,19 @@ declare module powerbi.extensibility.utils.dataview { function getFillColor(objects: DataViewObjects, propertyId: DataViewObjectPropertyIdentifier, defaultColor?: string): string; function getCommonValue(objects: DataViewObjects, propertyId: DataViewObjectPropertyIdentifier, defaultValue?: any): any; } - module DataViewObject { - function getValue(object: IDataViewObject, propertyName: string, defaultValue?: T): T; - /** Gets the solid color from a fill property using only a propertyName */ - function getFillColorByPropertyName(object: IDataViewObject, propertyName: string, defaultColor?: string): string; - } } declare module powerbi.extensibility.utils.dataview { import DataViewCategorical = powerbi.DataViewCategorical; import DataViewMetadataColumn = powerbi.DataViewMetadataColumn; import PrimitiveValue = powerbi.PrimitiveValue; + import MiscellaneousTypeDescriptor = powerbi.MiscellaneousTypeDescriptor; import DataView = powerbi.DataView; module converterHelper { function categoryIsAlsoSeriesRole(dataView: DataViewCategorical, seriesRoleName: string, categoryRoleName: string): boolean; function getSeriesName(source: DataViewMetadataColumn): PrimitiveValue; function isImageUrlColumn(column: DataViewMetadataColumn): boolean; function isWebUrlColumn(column: DataViewMetadataColumn): boolean; + function getMiscellaneousTypeDescriptor(column: DataViewMetadataColumn): MiscellaneousTypeDescriptor; function hasImageUrlColumn(dataView: DataView): boolean; } } @@ -68,7 +73,6 @@ declare module powerbi.extensibility.utils.dataview { } class DataViewObjectsParser { private static InnumerablePropertyPrefix; - private static createFillColorRegExp(fillColorNames); static getDefault(): DataViewObjectsParser; private static createPropertyIdentifier(objectName, propertyName); static parse(dataView: DataView): T; diff --git a/lib/index.js b/lib/index.js index 16f1445..530f774 100644 --- a/lib/index.js +++ b/lib/index.js @@ -80,6 +80,7 @@ var powerbi; } return groups; } + DataViewTransform.groupValues = groupValues; })(DataViewTransform = dataview.DataViewTransform || (dataview.DataViewTransform = {})); })(dataview = utils.dataview || (utils.dataview = {})); })(utils = extensibility.utils || (extensibility.utils = {})); @@ -161,7 +162,10 @@ var powerbi; } DataRoleHelper.hasRoleInDataView = hasRoleInDataView; function hasRoleInValueColumn(valueColumn, name) { - return valueColumn && valueColumn.source && valueColumn.source.roles && (valueColumn.source.roles[name] === true); + return valueColumn + && valueColumn.source + && valueColumn.source.roles + && (valueColumn.source.roles[name] === true); } DataRoleHelper.hasRoleInValueColumn = hasRoleInValueColumn; })(DataRoleHelper = dataview.DataRoleHelper || (dataview.DataRoleHelper = {})); @@ -195,6 +199,66 @@ var powerbi; * THE SOFTWARE. */ var powerbi; +(function (powerbi) { + var extensibility; + (function (extensibility) { + var utils; + (function (utils) { + var dataview; + (function (dataview) { + var DataViewObject; + (function (DataViewObject) { + function getValue(object, propertyName, defaultValue) { + if (!object) { + return defaultValue; + } + var propertyValue = object[propertyName]; + if (propertyValue === undefined) { + return defaultValue; + } + return propertyValue; + } + DataViewObject.getValue = getValue; + /** Gets the solid color from a fill property using only a propertyName */ + function getFillColorByPropertyName(object, propertyName, defaultColor) { + var value = getValue(object, propertyName); + if (!value || !value.solid) { + return defaultColor; + } + return value.solid.color; + } + DataViewObject.getFillColorByPropertyName = getFillColorByPropertyName; + })(DataViewObject = dataview.DataViewObject || (dataview.DataViewObject = {})); + })(dataview = utils.dataview || (utils.dataview = {})); + })(utils = extensibility.utils || (extensibility.utils = {})); + })(extensibility = powerbi.extensibility || (powerbi.extensibility = {})); +})(powerbi || (powerbi = {})); +/* + * Power BI Visualizations + * + * Copyright (c) Microsoft Corporation + * All rights reserved. + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the ""Software""), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +var powerbi; (function (powerbi) { var extensibility; (function (extensibility) { @@ -209,7 +273,7 @@ var powerbi; if (!objects) { return defaultValue; } - return DataViewObject.getValue(objects[propertyId.objectName], propertyId.propertyName, defaultValue); + return dataview.DataViewObject.getValue(objects[propertyId.objectName], propertyId.propertyName, defaultValue); } DataViewObjects.getValue = getValue; /** Gets an object from objects. */ @@ -243,29 +307,6 @@ var powerbi; } DataViewObjects.getCommonValue = getCommonValue; })(DataViewObjects = dataview.DataViewObjects || (dataview.DataViewObjects = {})); - var DataViewObject; - (function (DataViewObject) { - function getValue(object, propertyName, defaultValue) { - if (!object) { - return defaultValue; - } - var propertyValue = object[propertyName]; - if (propertyValue === undefined) { - return defaultValue; - } - return propertyValue; - } - DataViewObject.getValue = getValue; - /** Gets the solid color from a fill property using only a propertyName */ - function getFillColorByPropertyName(object, propertyName, defaultColor) { - var value = getValue(object, propertyName); - if (!value || !value.solid) { - return defaultColor; - } - return value.solid.color; - } - DataViewObject.getFillColorByPropertyName = getFillColorByPropertyName; - })(DataViewObject = dataview.DataViewObject || (dataview.DataViewObject = {})); })(dataview = utils.dataview || (utils.dataview = {})); })(utils = extensibility.utils || (extensibility.utils = {})); })(extensibility = powerbi.extensibility || (powerbi.extensibility = {})); @@ -339,6 +380,7 @@ var powerbi; && column.type && column.type.misc; } + converterHelper.getMiscellaneousTypeDescriptor = getMiscellaneousTypeDescriptor; function hasImageUrlColumn(dataView) { if (!dataView || !dataView.metadata || _.isEmpty(dataView.metadata.columns)) return false; @@ -386,13 +428,6 @@ var powerbi; var DataViewObjectsParser = (function () { function DataViewObjectsParser() { } - DataViewObjectsParser.createFillColorRegExp = function (fillColorNames) { - var formattedFillColorNames = fillColorNames - .reduce(function (previousValue, currentValue, index) { - return previousValue.concat((index ? "|" : "") + "(" + currentValue + ")"); - }, ""); - return new RegExp("^" + formattedFillColorNames + "$"); - }; DataViewObjectsParser.getDefault = function () { return new this(); }; diff --git a/lib/index.js.map b/lib/index.js.map index 333bcea..f92c119 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/dataViewTransform.ts","../src/dataRoleHelper.ts","../src/dataViewObject.ts","../src/converterHelper.ts","../src/dataViewObjectsParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,IAAO,OAAO,CAwE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AC;4CAChC,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;oCACjF,CAAC;gCACL,CAAC,CAAC,CAAC;4BACP,CAAC;wBACL,CAAC,CAAC,CAAC;wBAEH,MAAM,CAAC,UAAU,CAAC;oBACtB,CAAC;oBApGc,+CAAyB,GAAW,IAAI,CAAC;oBAqG5D,4BAAC;gBAAD,CAAC,AAtGD,IAsGC;gBAtGY,8BAAqB,wBAsGjC,CAAA;YACL,CAAC,EAxHkC,QAAQ,GAAR,cAAQ,KAAR,cAAQ,QAwH1C;QAAD,CAAC,EAxH4B,KAAK,GAAL,mBAAK,KAAL,mBAAK,QAwHjC;IAAD,CAAC,EAxHc,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAwH3B;AAAD,CAAC,EAxHM,OAAO,KAAP,OAAO,QAwHb"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/dataViewTransform.ts","../src/dataRoleHelper.ts","../src/dataViewObject.ts","../src/dataViewObjects.ts","../src/converterHelper.ts","../src/dataViewObjectsParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,IAAO,OAAO,CAwEb;AAxED,WAAO,OAAO;IAAC,IAAA,aAAa,CAwE3B;IAxEc,WAAA,aAAa;QAAC,IAAA,KAAK,CAwEjC;QAxE4B,WAAA,KAAK;YAAC,IAAA,QAAQ,CAwE1C;YAxEkC,WAAA,QAAQ,EAAC,CAAC;gBAUzC,0FAA0F;gBAC1F,IAAc,iBAAiB,CA4D9B;gBA5DD,WAAc,iBAAiB,EAAC,CAAC;oBAC7B,oGAAoG;oBACpG,4BACI,MAAkC,EAClC,mBAA+B,EAC/B,MAA+B;wBAF/B,sBAAkC,GAAlC,WAAkC;wBAGlC,IAAI,MAAM,GAAyB,MAAM,CAAC;wBAC1C,UAAU,CAAC,MAAM,CAAC,CAAC;wBAEnB,EAAE,CAAC,CAAC,mBAAmB,CAAC,CAAC,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;YACL,CAAC,EA/GkC,QAAQ,GAAR,cAAQ,KAAR,cAAQ,QA+G1C;QAAD,CAAC,EA/G4B,KAAK,GAAL,mBAAK,KAAL,mBAAK,QA+GjC;IAAD,CAAC,EA/Gc,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA+G3B;AAAD,CAAC,EA/GM,OAAO,KAAP,OAAO,QA+Gb"} \ No newline at end of file diff --git a/package.json b/package.json index 68a6ff2..a700c16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "powerbi-visuals-utils-dataviewutils", - "version": "1.0.1", + "version": "1.1.0", "description": "dataviewutils", "main": "lib/index.js", "repository": { diff --git a/src/converterHelper.ts b/src/converterHelper.ts index 3719081..f45632c 100644 --- a/src/converterHelper.ts +++ b/src/converterHelper.ts @@ -64,7 +64,7 @@ module powerbi.extensibility.utils.dataview { return misc != null && misc.webUrl === true; } - function getMiscellaneousTypeDescriptor(column: DataViewMetadataColumn): MiscellaneousTypeDescriptor { + export function getMiscellaneousTypeDescriptor(column: DataViewMetadataColumn): MiscellaneousTypeDescriptor { return column && column.type && column.type.misc; diff --git a/src/dataRoleHelper.ts b/src/dataRoleHelper.ts index f87317e..8681267 100644 --- a/src/dataRoleHelper.ts +++ b/src/dataRoleHelper.ts @@ -78,7 +78,10 @@ module powerbi.extensibility.utils.dataview { } export function hasRoleInValueColumn(valueColumn: DataViewValueColumn, name: string): boolean { - return valueColumn && valueColumn.source && valueColumn.source.roles && (valueColumn.source.roles[name] === true); + return valueColumn + && valueColumn.source + && valueColumn.source.roles + && (valueColumn.source.roles[name] === true); } } -} \ No newline at end of file +} diff --git a/src/dataViewObject.ts b/src/dataViewObject.ts index 08a0530..a3ecc76 100644 --- a/src/dataViewObject.ts +++ b/src/dataViewObject.ts @@ -25,77 +25,8 @@ */ module powerbi.extensibility.utils.dataview { - import DataViewObjects = powerbi.DataViewObjects; - import DataViewObjectPropertyIdentifier = powerbi.DataViewObjectPropertyIdentifier; + // powerbi import IDataViewObject = powerbi.DataViewObject; - import Fill = powerbi.Fill; - - export module DataViewObjects { - /** Gets the value of the given object/property pair. */ - export function getValue( - objects: DataViewObjects, - propertyId: DataViewObjectPropertyIdentifier, - defaultValue?: T): T { - - if (!objects) { - return defaultValue; - } - - return DataViewObject.getValue( - objects[propertyId.objectName], - propertyId.propertyName, - defaultValue); - } - - /** Gets an object from objects. */ - export function getObject( - objects: DataViewObjects, - objectName: string, - defaultValue?: IDataViewObject): IDataViewObject { - - if (objects && objects[objectName]) { - return objects[objectName]; - } - - return defaultValue; - } - - /** Gets the solid color from a fill property. */ - export function getFillColor( - objects: DataViewObjects, - propertyId: DataViewObjectPropertyIdentifier, - defaultColor?: string): string { - - const value: Fill = getValue(objects, propertyId); - - if (!value || !value.solid) { - return defaultColor; - } - - return value.solid.color; - } - - export function getCommonValue( - objects: DataViewObjects, - propertyId: DataViewObjectPropertyIdentifier, - defaultValue?: any): any { - - const value: any = getValue(objects, propertyId, defaultValue); - - if (value && (value as Fill).solid) { - return (value as Fill).solid.color; - } - - if (value === undefined - || value === null - || (typeof value === "object" && !(value as Fill).solid)) { - - return defaultValue; - } - - return value; - } - } export module DataViewObject { export function getValue(object: IDataViewObject, propertyName: string, defaultValue?: T): T { diff --git a/src/dataViewObjects.ts b/src/dataViewObjects.ts new file mode 100644 index 0000000..d8252b2 --- /dev/null +++ b/src/dataViewObjects.ts @@ -0,0 +1,97 @@ +/* + * Power BI Visualizations + * + * Copyright (c) Microsoft Corporation + * All rights reserved. + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the ""Software""), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +module powerbi.extensibility.utils.dataview { + // powerbi + import IDataViewObject = powerbi.DataViewObject; + + export module DataViewObjects { + /** Gets the value of the given object/property pair. */ + export function getValue( + objects: DataViewObjects, + propertyId: DataViewObjectPropertyIdentifier, + defaultValue?: T): T { + + if (!objects) { + return defaultValue; + } + + return DataViewObject.getValue( + objects[propertyId.objectName], + propertyId.propertyName, + defaultValue); + } + + /** Gets an object from objects. */ + export function getObject( + objects: DataViewObjects, + objectName: string, + defaultValue?: IDataViewObject): IDataViewObject { + + if (objects && objects[objectName]) { + return objects[objectName]; + } + + return defaultValue; + } + + /** Gets the solid color from a fill property. */ + export function getFillColor( + objects: DataViewObjects, + propertyId: DataViewObjectPropertyIdentifier, + defaultColor?: string): string { + + const value: Fill = getValue(objects, propertyId); + + if (!value || !value.solid) { + return defaultColor; + } + + return value.solid.color; + } + + export function getCommonValue( + objects: DataViewObjects, + propertyId: DataViewObjectPropertyIdentifier, + defaultValue?: any): any { + + const value: any = getValue(objects, propertyId, defaultValue); + + if (value && (value as Fill).solid) { + return (value as Fill).solid.color; + } + + if (value === undefined + || value === null + || (typeof value === "object" && !(value as Fill).solid)) { + + return defaultValue; + } + + return value; + } + } +} diff --git a/src/dataViewObjectsParser.ts b/src/dataViewObjectsParser.ts index 9402a5d..cdaff44 100644 --- a/src/dataViewObjectsParser.ts +++ b/src/dataViewObjectsParser.ts @@ -44,15 +44,6 @@ module powerbi.extensibility.utils.dataview { export class DataViewObjectsParser { private static InnumerablePropertyPrefix: RegExp = /^_/; - private static createFillColorRegExp(fillColorNames: string[]): RegExp { - let formattedFillColorNames: string = fillColorNames - .reduce((previousValue: string, currentValue: string, index: number) => { - return previousValue.concat(`${index ? "|" : ""}(${currentValue})`); - }, ""); - - return new RegExp(`^${formattedFillColorNames}$`); - } - public static getDefault() { return new this(); } diff --git a/src/dataViewTransform.ts b/src/dataViewTransform.ts index 8d5f483..3feda13 100644 --- a/src/dataViewTransform.ts +++ b/src/dataViewTransform.ts @@ -62,12 +62,12 @@ module powerbi.extensibility.utils.dataview { } /** Group together the values with a common identity. */ - function groupValues(values: DataViewValueColumn[]): DataViewValueColumnGroup[] { + export function groupValues(values: DataViewValueColumn[]): DataViewValueColumnGroup[] { let groups: DataViewValueColumnGroup[] = [], currentGroup: DataViewValueColumnGroup; for (let i = 0, len = values.length; i < len; i++) { - let value = values[i]; + let value: DataViewValueColumn = values[i]; if (!currentGroup || currentGroup.identity !== value.identity) { currentGroup = { @@ -77,7 +77,7 @@ module powerbi.extensibility.utils.dataview { if (value.identity) { currentGroup.identity = value.identity; - let source = value.source; + let source: DataViewMetadataColumn = value.source; // allow null, which will be formatted as (Blank). if (source.groupName !== undefined) { diff --git a/test/converterHelperTests.ts b/test/converterHelperTests.ts index db821d1..107121b 100644 --- a/test/converterHelperTests.ts +++ b/test/converterHelperTests.ts @@ -34,32 +34,227 @@ module powerbi.extensibility.utils.dataview.test { import converterHelper = powerbi.extensibility.utils.dataview.converterHelper; import DataViewTransform = powerbi.extensibility.utils.dataview.DataViewTransform; - describe("converterHelper tests", () => { - let dataViewBuilder: DataViewBuilder; - let dataView: DataViewCategorical; + describe("converterHelper", () => { + describe("categoryIsAlsoSeriesRole", () => { + let dataViewBuilder: DataViewBuilder, + dataView: DataViewCategorical; - beforeEach(() => { - dataViewBuilder = new DataViewBuilder(["a", "b"], [100, 200]); - dataView = dataViewBuilder.build(); + beforeEach(() => { + dataViewBuilder = new DataViewBuilder( + ["a", "b"], + [100, 200]); + + dataView = dataViewBuilder.build(); + }); + + it("default", () => { + expect(converterHelper.categoryIsAlsoSeriesRole( + dataView, + "Series", + "Category")).toBeFalsy(); + + // Only a "Series" role prevents us from using the Default strategy + dataViewBuilder.buildWithUpdateRoles({ + "Category": true + }); + + expect(converterHelper.categoryIsAlsoSeriesRole( + dataView, + "Series", + "Category")).toBeFalsy(); + + dataView = dataViewBuilder.buildWithUpdateRoles({ + "E === mc^2": true + }); + + expect(converterHelper.categoryIsAlsoSeriesRole( + dataView, + "Series", + "Category")).toBeFalsy(); + }); + + it("series and category", () => { + dataView = dataViewBuilder.buildWithUpdateRoles({ + "Series": true, + "Category": true + }); + + expect(converterHelper.categoryIsAlsoSeriesRole( + dataView, + "Series", + "Category")).toBe(true); + + dataView = dataViewBuilder.buildWithUpdateRoles({ + "Series": true, + "F === ma": true, + "Category": true + }); + + expect(converterHelper.categoryIsAlsoSeriesRole( + dataView, + "Series", + "Category")).toBe(true); + }); + + it("should return false if categories are empty", () => { + const categorical: DataViewCategorical = { + categories: [] + }; + + const actualResult: boolean = converterHelper.categoryIsAlsoSeriesRole( + categorical, + undefined, + undefined); + + expect(actualResult).toBeFalsy(); + }); }); - it("categoryIsAlsoSeriesRole default", () => { - expect(converterHelper.categoryIsAlsoSeriesRole(dataView, "Series", "Category")).toBeFalsy(); + describe("getSeriesName", () => { + it("should return the groupName if it's defined", () => { + const groupName: string = "Power BI", + metadata: DataViewMetadataColumn = { + displayName: undefined, + groupName + }; + + const actualSeriesName: string = converterHelper + .getSeriesName(metadata) as string; + + expect(actualSeriesName).toBe(groupName); + }); - // Only a "Series" role prevents us from using the Default strategy - dataViewBuilder.buildWithUpdateRoles({ "Category": true }); - expect(converterHelper.categoryIsAlsoSeriesRole(dataView, "Series", "Category")).toBeFalsy(); + it("should return the queryName if it's defined", () => { + const queryName: string = "Power BI", + metadata: DataViewMetadataColumn = { + displayName: undefined, + queryName + }; - dataView = dataViewBuilder.buildWithUpdateRoles({ "E === mc^2": true }); - expect(converterHelper.categoryIsAlsoSeriesRole(dataView, "Series", "Category")).toBeFalsy(); + const actualSeriesName: string = converterHelper + .getSeriesName(metadata) as string; + + expect(actualSeriesName).toBe(queryName); + }); }); - it("categoryIsAlsoSeriesRole series and category", () => { - dataView = dataViewBuilder.buildWithUpdateRoles({ "Series": true, "Category": true }); - expect(converterHelper.categoryIsAlsoSeriesRole(dataView, "Series", "Category")).toBe(true); + describe("getMiscellaneousTypeDescriptor", () => { + it("should return the misc object", () => { + const misc: MiscellaneousTypeDescriptor = { image: true }, + metadata: DataViewMetadataColumn = { + displayName: undefined, + type: { misc } + }; + + const actualMisc: MiscellaneousTypeDescriptor = converterHelper + .getMiscellaneousTypeDescriptor(metadata); + + expect(actualMisc).toBe(misc); + }); + }); + + describe("isImageUrlColumn", () => { + it("should return false if the misc is undefined", () => { + const actualImageUrl: boolean = converterHelper.isImageUrlColumn(undefined); + + expect(actualImageUrl).toBeFalsy(); + }); + + it("should return true if the imageUrl is defined", () => { + const misc: MiscellaneousTypeDescriptor = { imageUrl: true }, + metadata: DataViewMetadataColumn = { + displayName: undefined, + type: { misc } + }; + + const actualImageUrl: boolean = converterHelper.isImageUrlColumn(metadata); + + expect(actualImageUrl).toBe(misc.imageUrl); + }); + }); + + describe("isWebUrlColumn", () => { + it("should return false if the misc is undefined", () => { + const actualImageUrl: boolean = converterHelper.isWebUrlColumn(undefined); + + expect(actualImageUrl).toBeFalsy(); + }); + + it("should return true if the webUrl is defined", () => { + const misc: MiscellaneousTypeDescriptor = { webUrl: true }, + metadata: DataViewMetadataColumn = { + displayName: undefined, + type: { misc } + }; + + const actualWebUrl: boolean = converterHelper.isWebUrlColumn(metadata); + + expect(actualWebUrl).toBe(misc.webUrl); + }); + }); + + describe("hasImageUrlColumn", () => { + it("should return false if the dataView is undefined", () => { + const hasImageUrlColumn: boolean = converterHelper.hasImageUrlColumn(undefined); + + expect(hasImageUrlColumn).toBeFalsy(); + }); + + it("should return false if the dataView.metadata is undefined", () => { + const dataView: DataView = { + metadata: undefined + }; + + const hasImageUrlColumn: boolean = converterHelper.hasImageUrlColumn(dataView); + + expect(hasImageUrlColumn).toBeFalsy(); + }); + + it("should return false if the dataView.metadata.columns is undefined", () => { + const dataView: DataView = { + metadata: { + columns: undefined + } + }; + + const hasImageUrlColumn: boolean = converterHelper.hasImageUrlColumn(dataView); + + expect(hasImageUrlColumn).toBeFalsy(); + }); + + it("should return false if the imageUrl isn't available in the dataView", () => { + const dataView: DataView = getDataView(); + + const hasImageUrlColumn: boolean = converterHelper.hasImageUrlColumn(dataView); + + expect(hasImageUrlColumn).toBeFalsy(); + }); + + it("should return true if the imageUrl is available in the dataView", () => { + const expectedResult: boolean = true, + dataView: DataView = getDataView(expectedResult); + + const hasImageUrlColumn: boolean = converterHelper.hasImageUrlColumn(dataView); + + expect(hasImageUrlColumn).toBe(expectedResult); + }); - dataView = dataViewBuilder.buildWithUpdateRoles({ "Series": true, "F === ma": true, "Category": true }); - expect(converterHelper.categoryIsAlsoSeriesRole(dataView, "Series", "Category")).toBe(true); + function getDataView(imageUrl: boolean = false): DataView { + return { + metadata: { + columns: [{ + displayName: "", + }, { + displayName: "", + type: { + misc: { + imageUrl + } + } + }] + } + }; + } }); }); diff --git a/test/dataRoleHelperTest.ts b/test/dataRoleHelperTest.ts index b67fcde..93bf62c 100644 --- a/test/dataRoleHelperTest.ts +++ b/test/dataRoleHelperTest.ts @@ -35,114 +35,230 @@ module powerbi.extensibility.utils.dataview.test { import DataRoleHelper = powerbi.extensibility.utils.dataview.DataRoleHelper; import DataViewTransform = powerbi.extensibility.utils.dataview.DataViewTransform; - describe("dataRoleHelper tests", () => { - let dataViewBuilder: DataViewBuilder; - - beforeEach(() => { - dataViewBuilder = new DataViewBuilder(); - - dataViewBuilder.categoriesValues = ["Montana", "California", "Arizona"]; - dataViewBuilder.values = [ - [-100, 200, 700], - [1, 2, 3], - [4, 5, 6] - ]; - }); + describe("DataRoleHelper", () => { + describe("getMeasureIndexOfRole", () => { + let dataViewBuilder: DataViewBuilder; + + beforeEach(() => { + dataViewBuilder = new DataViewBuilder(); + + dataViewBuilder.categoriesValues = ["Montana", "California", "Arizona"]; + dataViewBuilder.values = [ + [-100, 200, 700], + [1, 2, 3], + [4, 5, 6] + ]; + }); + + it("getMeasureIndexOfRole with roles validation", () => { + dataViewBuilder.columns = [ + { displayName: "col1" }, + { displayName: "col2", isMeasure: true, roles: { "Size": true } }, + { displayName: "col3", isMeasure: true, roles: { "X": true } }, + { displayName: "col4", isMeasure: true, roles: { "Y": true } } + ]; - it("getMeasureIndexOfRole with roles validation", () => { - dataViewBuilder.columns = [ - {displayName: "col1"}, - {displayName: "col2", isMeasure: true, roles: {"Size": true}}, - {displayName: "col3", isMeasure: true, roles: {"X": true}}, - {displayName: "col4", isMeasure: true, roles: {"Y": true}} - ]; + let dataView: DataView = dataViewBuilder.build(); - let dataView: DataView = dataViewBuilder.build(); + let grouped = dataView.categorical.values.grouped(); - let grouped = dataView.categorical.values.grouped(); + let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "InvalidRoleName"); + expect(result).toBe(-1); - let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "InvalidRoleName"); - expect(result).toBe(-1); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); + expect(result).toBe(0); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); - expect(result).toBe(0); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "X"); + expect(result).toBe(1); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "X"); - expect(result).toBe(1); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Y"); + expect(result).toBe(2); + }); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Y"); - expect(result).toBe(2); - }); + it("getMeasureIndexOfRole without roles validation", () => { + dataViewBuilder.columns = [ + { displayName: "col1" }, + { displayName: "col2", isMeasure: true }, + { displayName: "col3", isMeasure: true }, + { displayName: "col4", isMeasure: true } + ]; - it("getMeasureIndexOfRole without roles validation", () => { - dataViewBuilder.columns = [ - { displayName: "col1" }, - { displayName: "col2", isMeasure: true }, - { displayName: "col3", isMeasure: true }, - { displayName: "col4", isMeasure: true } - ]; + let dataView: DataView = dataViewBuilder.build(); - let dataView: DataView = dataViewBuilder.build(); + let grouped = dataView.categorical.values.grouped(); - let grouped = dataView.categorical.values.grouped(); + let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "InvalidRoleName"); + expect(result).toBe(-1); - let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "InvalidRoleName"); - expect(result).toBe(-1); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); + expect(result).toBe(-1); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); - expect(result).toBe(-1); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "X"); + expect(result).toBe(-1); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "X"); - expect(result).toBe(-1); + result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Y"); + expect(result).toBe(-1); + }); - result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Y"); - expect(result).toBe(-1); - }); + it("getMeasureIndexOfRole without roles validation with default", () => { + dataViewBuilder.columns = [ + { displayName: "col1" }, + { displayName: "col2", isMeasure: true }, + { displayName: "col3", isMeasure: true }, + { displayName: "col4", isMeasure: true } + ]; - it("getMeasureIndexOfRole without roles validation with default", () => { - dataViewBuilder.columns = [ - {displayName: "col1"}, - {displayName: "col2", isMeasure: true}, - {displayName: "col3", isMeasure: true}, - {displayName: "col4", isMeasure: true} - ]; + let dataView: DataView = dataViewBuilder.build(); - let dataView: DataView = dataViewBuilder.build(); + let grouped = dataView.categorical.values.grouped(); - let grouped = dataView.categorical.values.grouped(); + let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); + expect(result).toBe(-1); + }); - let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "Size"); - expect(result).toBe(-1); - }); + it("getMeasureIndexOfRole without roles validation with default too few measures", () => { + dataViewBuilder.values = [[-1, 2, 3]]; - it("getMeasureIndexOfRole without roles validation with default too few measures", () => { - dataViewBuilder.values = [[-1, 2, 3]]; + dataViewBuilder.columns = [ + { displayName: "col1" }, + { displayName: "col2", isMeasure: true } + ]; - dataViewBuilder.columns = [ - {displayName: "col1"}, - {displayName: "col2", isMeasure: true} - ]; + let dataView: DataView = dataViewBuilder.build(); - let dataView: DataView = dataViewBuilder.build(); + let grouped = dataView.categorical.values.grouped(); - let grouped = dataView.categorical.values.grouped(); + let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "2nd measure"); + expect(result).toBe(-1); + }); + }); - let result = DataRoleHelper.getMeasureIndexOfRole(grouped, "2nd measure"); - expect(result).toBe(-1); + describe("hasRoleInDataView", () => { + it("should return true is the role is available", () => { + const dataView: DataView = getDataView(); + + expect(DataRoleHelper.hasRoleInDataView(dataView, "Series")).toBe(true); + }); + + it("should return false is the role isn't available", () => { + const dataView: DataView = getDataView(); + + expect(DataRoleHelper.hasRoleInDataView(dataView, "Category")).toBe(false); + }); + + function getDataView(): DataView { + return { + metadata: { + columns: [ + { + displayName: "col1", + roles: { "Series": true } + }, + { + displayName: "col2", + isMeasure: true, + roles: { "Size": true } + } + ] + } + }; + } }); - it("hasRoleInDataView", () => { - let dataViewMetadata: DataViewMetadata = { - columns: [ - { displayName: "col1", roles: { "Series": true } }, - { displayName: "col2", isMeasure: true, roles: { "Size": true } }, - ] - }; - let dataView: DataView = { - metadata: dataViewMetadata - }; - expect(DataRoleHelper.hasRoleInDataView(dataView, "Series")).toBe(true); - expect(DataRoleHelper.hasRoleInDataView(dataView, "Category")).toBe(false); + describe("getCategoryIndexOfRole", () => { + const seriesRoleName: string = "Series", + sizeRoleName: string = "Size"; + + it("should return -1 if the categories is empty", () => { + const expectedIndex: number = -1; + + const actualIndex: number = DataRoleHelper.getCategoryIndexOfRole([], undefined); + + expect(actualIndex).toBe(expectedIndex); + }); + + it("should return -1 if the role isn't available", () => { + const expectedIndex: number = -1, + categoryColumns: DataViewCategoricalColumn[] = getCategoryColumns( + seriesRoleName, + sizeRoleName); + + const actualIndex: number = DataRoleHelper.getCategoryIndexOfRole( + categoryColumns, + "Power BI"); + + expect(actualIndex).toBe(expectedIndex); + }); + + it("should return -1 if the role isn't available", () => { + const expectedIndex: number = 1, + categoryColumns: DataViewCategoricalColumn[] = getCategoryColumns( + seriesRoleName, + sizeRoleName); + + const actualIndex: number = DataRoleHelper.getCategoryIndexOfRole( + categoryColumns, + sizeRoleName); + + expect(actualIndex).toBe(expectedIndex); + }); + + function getCategoryColumns( + seriesRoleName: string, + sizeRoleName: string): DataViewCategoricalColumn[] { + + return [{ + source: { + displayName: "col1", + roles: { [seriesRoleName]: true } + }, + values: [] + }, + { + source: { + displayName: "col2", + isMeasure: true, + roles: { [sizeRoleName]: true } + }, + values: [] + }]; + } + }); + + describe("hasRoleInValueColumn", () => { + const roleName: string = "Series"; + + it("should return false if role name is undefined", () => { + const valueColumn: DataViewValueColumn = getValueColumn(roleName); + + const hasRole: boolean = DataRoleHelper.hasRoleInValueColumn( + valueColumn, + "Power BI"); + + expect(hasRole).toBeFalsy(); + }); + + it("should return true if role name is available", () => { + const valueColumn: DataViewValueColumn = getValueColumn(roleName); + + const hasRole: boolean = DataRoleHelper.hasRoleInValueColumn( + valueColumn, + roleName); + + expect(hasRole).toBeTruthy(); + }); + + function getValueColumn(roleName: string): DataViewValueColumn { + return { + source: { + displayName: "", + roles: { + [roleName]: true + } + }, + values: [] + }; + } }); }); diff --git a/test/dataViewObjectTest.ts b/test/dataViewObjectTest.ts index 1e10262..bebb43f 100644 --- a/test/dataViewObjectTest.ts +++ b/test/dataViewObjectTest.ts @@ -27,91 +27,95 @@ /// module powerbi.extensibility.utils.dataview.test { + // powerbi + import IDataViewObject = powerbi.DataViewObject; + // powerbi.extensibility.utils.dataview - import DataViewObjects = powerbi.extensibility.utils.dataview.DataViewObjects; - - describe("DataViewObjects", () => { - const fillColor: string = "green", - fontSize: number = 22, - groupName: string = "general", - fillColorName: string = "fillColor", - fontSizeName: string = "fontSize", - fillColorProperty: DataViewObjectPropertyIdentifier = { - objectName: groupName, - propertyName: fillColorName - }, - fontSizeProperty: DataViewObjectPropertyIdentifier = { - objectName: groupName, - propertyName: fontSizeName - }; + import DataViewObject = powerbi.extensibility.utils.dataview.DataViewObject; - function createDataViewObjects( - generalFillColor: string = fillColor, - generalFontSize: any = fontSize): DataViewObjects { + describe("DataViewObject", () => { + const fontSizePropertyName: string = "fontSize", + fillColorPropertyName: string = "fillColor", + fontSize: string = "11em", + fillColor: string = "green"; + + function getDataViewObject( + fontSize: any, + fillColor: string): IDataViewObject { return { - [groupName]: { - [fillColorName]: { solid: { color: generalFillColor } }, - [fontSizeName]: generalFontSize - } + [fontSizePropertyName]: fontSize, + [fillColorPropertyName]: { solid: { color: fillColor } } }; } - describe("getCommonValue", () => { - it("should return the correct color", () => { - const objects: DataViewObjects = createDataViewObjects(); - - const actualValue: string = DataViewObjects.getCommonValue( - objects, - fillColorProperty); + describe("getValue", () => { + it("should return the default value if the object is undefined", () => { + const actualFontSize: string = DataViewObject.getValue( + undefined, + undefined, + fontSize); - expect(actualValue).toBe(fillColor); + expect(actualFontSize).toBe(fontSize); }); - it("should return the default value if property is undefined", () => { - const objects: DataViewObjects = {}; + it("should return the default value if the property isn't available in the object", () => { + const object: IDataViewObject = getDataViewObject(fontSize, fontSize); - const actualValue: string = DataViewObjects.getCommonValue( - objects, - fillColorProperty, + const actualFontSize: string = DataViewObject.getValue( + object, + "Power BI", + fontSize); + + expect(actualFontSize).toBe(fontSize); + }); + }); + + describe("getFillColorByPropertyName", () => { + it("should return a default color if the object is undefined", () => { + const actualFillColor: string = DataViewObject.getFillColorByPropertyName( + undefined, + undefined, fillColor); - expect(actualValue).toBe(fillColor); + expect(actualFillColor).toBe(fillColor); }); - it("should return the correct value", () => { - const objects: DataViewObjects = createDataViewObjects(); + it("should return a default color if property isn't available in the object", () => { + const object: IDataViewObject = getDataViewObject(fontSize, fillColor); - const actualValue: string = DataViewObjects.getCommonValue( - objects, - fontSizeProperty); + const actualFillColor: string = DataViewObject.getFillColorByPropertyName( + object, + "Power BI", + fillColor); - expect(actualValue).toBe(fontSize); + expect(actualFillColor).toBe(fillColor); }); - it("should return value of the default value if object is an empty object and default value is null", () => { - const objects: DataViewObjects = {}, - defaultValue: any = null; + it("should return a default color if the solid is undefined", () => { + const object: IDataViewObject = getDataViewObject(fontSize, fillColor); + + object[fillColorPropertyName]["solid"] = undefined; - const actualValue: string = DataViewObjects.getCommonValue( - objects, - fontSizeProperty, - defaultValue); + const actualFillColor: string = DataViewObject.getFillColorByPropertyName( + object, + fillColorPropertyName, + fillColor); - expect(actualValue).toBe(defaultValue); + expect(actualFillColor).toBe(fillColor); }); - it("should return false is the property defined as false", () => { - const expectedValue: boolean = false, - objects: DataViewObjects = createDataViewObjects(null, expectedValue); + it("should return the color", () => { + const object: IDataViewObject = getDataViewObject(fontSize, fillColor); - const actualValue: string = DataViewObjects.getCommonValue( - objects, - fontSizeProperty, - "Power BI"); + const actualFillColor: string = DataViewObject.getFillColorByPropertyName( + object, + fillColorPropertyName); - expect(actualValue).toBe(expectedValue); + expect(actualFillColor).toBe(fillColor); }); }); }); + + } diff --git a/test/dataViewObjectsParserTest.ts b/test/dataViewObjectsParserTest.ts index 9980c29..62e5b1c 100644 --- a/test/dataViewObjectsParserTest.ts +++ b/test/dataViewObjectsParserTest.ts @@ -76,20 +76,26 @@ module powerbi.extensibility.utils.dataview.test { }); describe("parse", () => { - let properties: DataViewObjectsParserWithProperties; - - beforeEach(() => { - properties = DataViewObjectsParserWithProperties + it("should return the correct color value", () => { + const properties: DataViewObjectsParserWithProperties = DataViewObjectsParserWithProperties .parse(createDataView()); - }); - it("should return the correct color value", () => { expect(properties.general.fillColor).toBe(fillColor); }); it("should return the correct value", () => { + const properties: DataViewObjectsParserWithProperties = DataViewObjectsParserWithProperties + .parse(createDataView()); + expect(properties.general.precision).toBe(precision); }); + + it("should return default settings if the dataView is undefined", () => { + const properties: DataViewObjectsParserWithProperties = DataViewObjectsParserWithProperties + .parse(null); + + expect(properties).toBeDefined(); + }); }); describe("enumerateObjectInstances", () => { diff --git a/test/dataViewObjectsTest.ts b/test/dataViewObjectsTest.ts new file mode 100644 index 0000000..275121b --- /dev/null +++ b/test/dataViewObjectsTest.ts @@ -0,0 +1,204 @@ +/* + * Power BI Visualizations + * + * Copyright (c) Microsoft Corporation + * All rights reserved. + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the ""Software""), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/// + +module powerbi.extensibility.utils.dataview.test { + // powerbi + import IDataViewObject = powerbi.DataViewObject; + import IDataViewObjects = powerbi.DataViewObjects; + + // powerbi.extensibility.utils.dataview + import DataViewObjects = powerbi.extensibility.utils.dataview.DataViewObjects; + + describe("DataViewObjects", () => { + const fillColor: string = "green", + fontSize: number = 22, + groupName: string = "general", + fillColorName: string = "fillColor", + fontSizeName: string = "fontSize", + fillColorProperty: DataViewObjectPropertyIdentifier = { + objectName: groupName, + propertyName: fillColorName + }, + fontSizeProperty: DataViewObjectPropertyIdentifier = { + objectName: groupName, + propertyName: fontSizeName + }; + + function createDataViewObjects( + generalFillColor: string, + generalFontSize: any): DataViewObjects { + + return { + [groupName]: { + [fillColorName]: { solid: { color: generalFillColor } }, + [fontSizeName]: generalFontSize + } + }; + } + + describe("getValue", () => { + it("should return a default value if objects are undefined", () => { + const defaultValue: string = "DefaultValue"; + + const actualValue: string = DataViewObjects.getValue( + undefined, + undefined, + defaultValue); + + expect(actualValue).toBe(defaultValue); + }); + }); + + describe("getObject", () => { + it("should return a default object is objects are undefined", () => { + const defaultValue: IDataViewObject = {}; + + const actualValue: IDataViewObject = DataViewObjects.getObject( + undefined, + undefined, + defaultValue); + + expect(actualValue).toBe(defaultValue); + }); + + it("should return an object by its name", () => { + const objects: IDataViewObjects = createDataViewObjects( + fillColor, + fontSize); + + const actualValue: IDataViewObject = DataViewObjects.getObject( + objects, + groupName); + + expect(actualValue).toBe(objects[groupName]); + }); + }); + + describe("getFillColor", () => { + it("should return the default color is objects are undefined", () => { + const defaultColor: string = "green"; + + const actualColor: string = DataViewObjects.getFillColor( + undefined, + undefined, + defaultColor); + + expect(actualColor).toBe(defaultColor); + }); + + it("should return a color by its property name", () => { + const objects: IDataViewObjects = createDataViewObjects( + fillColor, + fontSize); + + const actualColor: string = DataViewObjects.getFillColor( + objects, + fillColorProperty); + + expect(actualColor).toBe(fillColor); + }); + }); + + describe("getCommonValue", () => { + it("should return the defaultColor if the solid is undefined", () => { + const defaultColor: string = "yellow", + objects: DataViewObjects = createDataViewObjects( + fillColor, + fontSize); + + objects[groupName][fillColorName]["solid"] = null; + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fillColorProperty, + defaultColor); + + expect(actualValue).toBe(defaultColor); + }); + + it("should return the correct color", () => { + const objects: DataViewObjects = createDataViewObjects( + fillColor, + fontSize); + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fillColorProperty); + + expect(actualValue).toBe(fillColor); + }); + + it("should return the default value if property is undefined", () => { + const objects: DataViewObjects = {}; + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fillColorProperty, + fillColor); + + expect(actualValue).toBe(fillColor); + }); + + it("should return the correct value", () => { + const objects: DataViewObjects = createDataViewObjects( + fillColor, + fontSize); + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fontSizeProperty); + + expect(actualValue).toBe(fontSize); + }); + + it("should return value of the default value if object is an empty object and default value is null", () => { + const objects: DataViewObjects = {}, + defaultValue: any = null; + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fontSizeProperty, + defaultValue); + + expect(actualValue).toBe(defaultValue); + }); + + it("should return false is the property defined as false", () => { + const expectedValue: boolean = false, + objects: DataViewObjects = createDataViewObjects(null, expectedValue); + + const actualValue: string = DataViewObjects.getCommonValue( + objects, + fontSizeProperty, + "Power BI"); + + expect(actualValue).toBe(expectedValue); + }); + }); + }); +} diff --git a/test/dataViewTransformTest.ts b/test/dataViewTransformTest.ts new file mode 100644 index 0000000..ea8d5f1 --- /dev/null +++ b/test/dataViewTransformTest.ts @@ -0,0 +1,134 @@ +/* + * Power BI Visualizations + * + * Copyright (c) Microsoft Corporation + * All rights reserved. + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the ""Software""), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/// + +module powerbi.extensibility.utils.dataview.test { + // data + import ISQExpr = data.ISQExpr; + + // powerbi.extensibility.utils.dataview + import DataViewTransform = powerbi.extensibility.utils.dataview.DataViewTransform; + + describe("DataViewTransform", () => { + describe("createValueColumns", () => { + it("the grouped function should be defined", () => { + const valueColumn: DataViewValueColumn = getDataViewValueColumn(); + + const valueColumns: DataViewValueColumns = DataViewTransform.createValueColumns([valueColumn]); + + expect(valueColumns.grouped).toBeDefined(); + }); + + it("the identityFields should be set correctly", () => { + const valueColumn: DataViewValueColumn = getDataViewValueColumn(), + valueIdentityFields: ISQExpr[] = [{}, {}]; + + const valueColumns: DataViewValueColumns = DataViewTransform.createValueColumns( + [valueColumn], + valueIdentityFields); + + expect(valueColumns.identityFields).toBe(valueIdentityFields); + }); + + it("the source should be set correctly", () => { + const valueColumn: DataViewValueColumn = getDataViewValueColumn(), + source: DataViewMetadataColumn = { + displayName: "Test DataView Column" + }; + + const valueColumns: DataViewValueColumns = DataViewTransform.createValueColumns( + [valueColumn], + undefined, + source); + + expect(valueColumns.source).toBe(source); + }); + }); + + describe("setGrouped", () => { + it("the grouped should be set correctly", () => { + const valueColumn: DataViewValueColumn[] = [getDataViewValueColumn()], + groupedResult: DataViewValueColumnGroup[] = []; + + DataViewTransform.setGrouped( + valueColumn as DataViewValueColumns, + groupedResult); + + expect((valueColumn as DataViewValueColumns).grouped()).toBe(groupedResult); + }); + }); + + describe("groupValues", () => { + it("the identity should be set correctly", () => { + const identity: DataViewScopeIdentity = getIdentity(), + valueColumn: DataViewValueColumn[] = [getDataViewValueColumn(identity)]; + + const columnGroups: DataViewValueColumnGroup[] = DataViewTransform.groupValues(valueColumn); + + expect(columnGroups[0].identity).toBe(identity); + }); + + it("group name and the groupName of source should be the same", () => { + const identity: DataViewScopeIdentity = getIdentity(), + groupName: string = "TestGroupName", + valueColumn: DataViewValueColumn[] = [getDataViewValueColumn(identity, groupName)]; + + const columnGroups: DataViewValueColumnGroup[] = DataViewTransform.groupValues(valueColumn); + + expect(columnGroups[0].name).toBe(groupName); + }); + + it("group name and the displayName of source should be the same", () => { + const identity: DataViewScopeIdentity = getIdentity(), + valueColumn: DataViewValueColumn[] = [getDataViewValueColumn(identity)], + displayName: string = valueColumn[0].source.displayName as string; + + const columnGroups: DataViewValueColumnGroup[] = DataViewTransform.groupValues(valueColumn); + + expect(columnGroups[0].name).toBe(displayName); + }); + }); + }); + + function getDataViewValueColumn(identity?: DataViewScopeIdentity, groupName?: string): DataViewValueColumn { + return { + identity, + source: { + groupName, + displayName: "TestColumn" + }, + values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + }; + } + + function getIdentity(): DataViewScopeIdentity { + return { + expr: {}, + key: "TestKey" + }; + } +} diff --git a/tsconfig.json b/tsconfig.json index 7ab76c5..8c78558 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "src/dataViewTransform.ts", "src/dataRoleHelper.ts", "src/dataViewObject.ts", + "src/dataViewObjects.ts", "src/converterHelper.ts", "src/dataViewObjectsParser.ts" ]