diff --git a/karma.conf.ts b/karma.conf.ts index ee7f884..f859313 100644 --- a/karma.conf.ts +++ b/karma.conf.ts @@ -36,7 +36,18 @@ const coverageFolder = "coverage"; process.env.CHROME_BIN = require('playwright-chromium').chromium.executablePath(); module.exports = (config) => { config.set({ - browsers: ["ChromeHeadless"], + browsers: ["ChromeHeadlessNoSandbox"], + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + flags: [ + "--no-sandbox", + "--disable-setuid-sandbox", + "--disable-gpu", + "--disable-dev-shm-usage" + ] + } + }, colors: true, frameworks: ["jasmine"], reporters: [ diff --git a/package-lock.json b/package-lock.json index 1639820..9d84239 100644 --- a/package-lock.json +++ b/package-lock.json @@ -135,6 +135,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.23.5", @@ -917,6 +918,7 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.3.tgz", "integrity": "sha512-sD+ia2ubTeWrOu+YMF+MTAB7E+O7qsMqAbMfW7DG3K1URwhZ5hN1pLlRVGbf4wDFzSfikL05M17EyorS86jShw==", "dev": true, + "peer": true, "dependencies": { "undici-types": "~5.26.4" } @@ -983,6 +985,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "dev": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "5.62.0", "@typescript-eslint/types": "5.62.0", @@ -1314,6 +1317,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1353,6 +1357,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -1707,6 +1712,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001565", "electron-to-chromium": "^1.4.601", @@ -2548,6 +2554,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -3920,6 +3927,7 @@ "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.3.tgz", "integrity": "sha512-LuucC/RE92tJ8mlCwqEoRWXP38UMAqpnq98vktmS9SznSoUPPUJQbc91dHcxcunROvfQjdORVA/YFviH+Xci9Q==", "dev": true, + "peer": true, "dependencies": { "@colors/colors": "1.5.0", "body-parser": "^1.19.0", @@ -5941,6 +5949,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -6151,6 +6160,7 @@ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.90.3.tgz", "integrity": "sha512-h6uDYlWCctQRuXBs1oYpVe6sFcWedl0dpcVaTf/YF67J9bKvwJajFulMVSYKHrksMB3I/pIagRzDxwxkebuzKA==", "dev": true, + "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", diff --git a/src/dataViewBuilder/testDataViewBuilder.ts b/src/dataViewBuilder/testDataViewBuilder.ts index 4b707eb..1e478f8 100644 --- a/src/dataViewBuilder/testDataViewBuilder.ts +++ b/src/dataViewBuilder/testDataViewBuilder.ts @@ -240,7 +240,7 @@ export abstract class TestDataViewBuilder { protected createCategoricalDataViewBuilder( categoriesColumns: (TestDataViewBuilderCategoryColumnOptions | TestDataViewBuilderCategoryColumnOptions[])[], valuesColumns: (DataViewBuilderValuesColumnOptions | DataViewBuilderValuesColumnOptions[])[], - columnNames: string[], + columnNames?: string[], customizeColumns?: CustomizeColumnFn): IDataViewBuilderCategorical { const builder = createCategoricalDataViewBuilder(); diff --git a/src/mocks/mockIColorPalette.ts b/src/mocks/mockIColorPalette.ts index 8f65580..2f38477 100644 --- a/src/mocks/mockIColorPalette.ts +++ b/src/mocks/mockIColorPalette.ts @@ -29,6 +29,7 @@ import powerbi from "powerbi-visuals-api"; import IColorPalette = powerbi.extensibility.ISandboxExtendedColorPalette; import IColorInfo = powerbi.IColorInfo; + export class MockIColorPalette implements IColorPalette { /** * This array represents the default colors of the IColorPalette. @@ -86,8 +87,8 @@ export class MockIColorPalette implements IColorPalette { private colors: IColorInfo[]; private colorIndex: number = 0; - constructor(colors: IColorInfo[] = []) { - this.colors = colors; + constructor(colors?: IColorInfo[]) { + this.colors = colors || []; } public getColor(key: string): IColorInfo { @@ -107,33 +108,34 @@ export class MockIColorPalette implements IColorPalette { } public isHighContrast: true; - public foreground = {value: "#333333" }; - public foregroundLight = {value: "#FFF" }; - public foregroundDark = {value: "#000" }; - public foregroundNeutralLight = {value: "#EAEAEA" }; - public foregroundNeutralDark = {value: "#212121" }; - public foregroundNeutralSecondary = {value: "#666666" }; - public foregroundNeutralSecondaryAlt = {value: "#777777" }; - public foregroundNeutralSecondaryAlt2 = {value: "#888888" }; - public foregroundNeutralTertiary = {value: "#A6A6A6" }; - public foregroundNeutralTertiaryAlt = {value: "#C8C8C8" }; - public foregroundSelected = {value: "#333333" }; - public foregroundButton = {value: "#666666" }; - public background = {value: "#FFF" }; - public backgroundLight = {value: "#EAEAEA" }; - public backgroundNeutral = {value: "#C8C8C8" }; - public backgroundDark = {value: "#000" }; - public hyperlink = {value: "#1F3A93" }; - public visitedHyperlink = {value: "#551A8B" }; - public mapPushpin = {value: "#FF5F00" }; - public shapeStroke = {value: "#01B8AA" }; - public selection = {value: undefined }; - public separator = {value: undefined }; - public negative = {value: undefined }; - public neutral = {value: undefined }; - public positive = {value: undefined }; + public foreground = { value: "#333333" }; + public foregroundLight = { value: "#FFF" }; + public foregroundDark = { value: "#000" }; + public foregroundNeutralLight = { value: "#EAEAEA" }; + public foregroundNeutralDark = { value: "#212121" }; + public foregroundNeutralSecondary = { value: "#666666" }; + public foregroundNeutralSecondaryAlt = { value: "#777777" }; + public foregroundNeutralSecondaryAlt2 = { value: "#888888" }; + public foregroundNeutralTertiary = { value: "#A6A6A6" }; + public foregroundNeutralTertiaryAlt = { value: "#C8C8C8" }; + public foregroundSelected = { value: "#333333" }; + public foregroundButton = { value: "#666666" }; + public background = { value: "#FFF" }; + public backgroundLight = { value: "#EAEAEA" }; + public backgroundNeutral = { value: "#C8C8C8" }; + public backgroundDark = { value: "#000" }; + public hyperlink = { value: "#1F3A93" }; + public visitedHyperlink = { value: "#551A8B" }; + public mapPushpin = { value: "#FF5F00" }; + public shapeStroke = { value: "#01B8AA" }; + public selection = { value: undefined }; + public separator = { value: undefined }; + public negative = { value: undefined }; + public neutral = { value: undefined }; + public positive = { value: undefined }; public reset(): IColorPalette { + this.colorIndex = 0; return this; } } \ No newline at end of file diff --git a/test/dataViewBuilder/testDataViewBuilderTest.ts b/test/dataViewBuilder/testDataViewBuilderTest.ts index 7114ef9..872a67b 100644 --- a/test/dataViewBuilder/testDataViewBuilderTest.ts +++ b/test/dataViewBuilder/testDataViewBuilderTest.ts @@ -47,29 +47,29 @@ describe("TestDataViewBuilder", () => { it("dataView.categorical should be correct", () => { expect(dataView.categorical).toBeDefined(); - expect(dataView.categorical.categories.length).toBe(1); + expect(dataView.categorical!.categories!.length).toBe(1); - expect(dataView.categorical.categories[0]).toBeDefined(); - expect(dataView.categorical.categories[0].identity.length).toBe(2); - expect(dataView.categorical.categories[0].identityFields.length).toBe(1); + expect(dataView.categorical!.categories![0]).toBeDefined(); + expect(dataView.categorical!.categories![0].identity!.length).toBe(2); + expect(dataView.categorical!.categories![0].identityFields!.length).toBe(1); - expect(dataView.categorical.categories[0].source).toBeDefined(); - expect(dataView.categorical.categories[0].source.displayName).toBe(TestDataViewBuilderImplementation.ColumnSource); - expect(dataView.categorical.categories[0].source.roles[TestDataViewBuilderImplementation.ColumnSource]).toBeTruthy(); + expect(dataView.categorical!.categories![0].source).toBeDefined(); + expect(dataView.categorical!.categories![0].source.displayName).toBe(TestDataViewBuilderImplementation.ColumnSource); + expect(dataView.categorical!.categories![0].source.roles![TestDataViewBuilderImplementation.ColumnSource]).toBeTruthy(); - expect(dataView.categorical.categories[0].values).toBeDefined(); - expect(dataView.categorical.categories[0].values[0]).toBe(TestDataViewBuilderImplementation.Column1); - expect(dataView.categorical.categories[0].values[1]).toBe(TestDataViewBuilderImplementation.Column2); + expect(dataView.categorical!.categories![0].values).toBeDefined(); + expect(dataView.categorical!.categories![0].values[0]).toBe(TestDataViewBuilderImplementation.Column1); + expect(dataView.categorical!.categories![0].values[1]).toBe(TestDataViewBuilderImplementation.Column2); - expect(dataView.categorical.values).toBeDefined(); - expect(dataView.categorical.values.length).toBe(1); + expect(dataView.categorical!.values).toBeDefined(); + expect(dataView.categorical!.values!.length).toBe(1); - expect(dataView.categorical.values[0].source).toBeDefined(); - expect(dataView.categorical.values[0].source.displayName).toBe(TestDataViewBuilderImplementation.ColumnValue); - expect(dataView.categorical.values[0].source.isMeasure).toBeTruthy(); + expect(dataView.categorical!.values![0].source).toBeDefined(); + expect(dataView.categorical!.values![0].source.displayName).toBe(TestDataViewBuilderImplementation.ColumnValue); + expect(dataView.categorical!.values![0].source.isMeasure).toBeTruthy(); - expect(dataView.categorical.values[0].values[0]).toBe(TestDataViewBuilderImplementation.Value1); - expect(dataView.categorical.values[0].values[1]).toBe(TestDataViewBuilderImplementation.Value2); + expect(dataView.categorical!.values![0].values[0]).toBe(TestDataViewBuilderImplementation.Value1); + expect(dataView.categorical!.values![0].values[1]).toBe(TestDataViewBuilderImplementation.Value2); }); it("dataView.metadata should be correct", () => { @@ -80,10 +80,10 @@ describe("TestDataViewBuilder", () => { expect(dataView.metadata.columns[1]).toBeDefined(); expect(dataView.metadata.columns[0].displayName).toBe(TestDataViewBuilderImplementation.ColumnSource); - expect(dataView.metadata.columns[0].roles[TestDataViewBuilderImplementation.ColumnSource]).toBeTruthy(); + expect(dataView.metadata.columns[0].roles![TestDataViewBuilderImplementation.ColumnSource]).toBeTruthy(); expect(dataView.metadata.columns[1].displayName).toBe(TestDataViewBuilderImplementation.ColumnValue); - expect(dataView.metadata.columns[1].roles[TestDataViewBuilderImplementation.ColumnValue]).toBeTruthy(); + expect(dataView.metadata.columns[1].roles![TestDataViewBuilderImplementation.ColumnValue]).toBeTruthy(); }); }); }); @@ -190,43 +190,43 @@ describe("test MatrixDataViewBuilder ", () => { } ] }; - expect(dataView.matrix.columns.root).toEqual(root); - expect(dataView.matrix.columns.levels[0].sources[0].displayName).toBe("Revenue Budget"); - expect(dataView.matrix.columns.levels[0].sources[1].displayName).toBe("Total COGS"); + expect(dataView.matrix!.columns.root).toEqual(root); + expect(dataView.matrix!.columns.levels[0].sources[0].displayName).toBe("Revenue Budget"); + expect(dataView.matrix!.columns.levels[0].sources[1].displayName).toBe("Total COGS"); }); it("dataview should be populated with valid measures", () => { - const root = dataView.matrix.rows.root; - const coreIndex = root.children.findIndex(el => el.value === "Core"); - expect(root.children[coreIndex].children[1].values).toEqual({ 0: { value: 1191435 }, 1: { value: 1419847.51, valueSourceIndex: 1 } }); - expect(root.children[coreIndex].children[2].values).toEqual({ 0: { value: 27199561.42 }, 1: { value: 35353245.96, valueSourceIndex: 1 } }); - expect(root.children[coreIndex].children[3].values).toEqual({ 0: { value: 35763040.53 }, 1: { value: 45951725.04, valueSourceIndex: 1 } }); - expect(root.children[coreIndex].children[4].values).toEqual({ 0: { value: 2507806.098 }, 1: { value: 3151651.45, valueSourceIndex: 1 } }); - expect(root.children[coreIndex].children[5].values).toEqual({ 0: { value: 374458.462 }, 1: { value: 688982.45, valueSourceIndex: 1 } }); - - const growthIndex = root.children.findIndex(el => el.value === "Growth"); - expect(root.children[growthIndex].children[1].values).toEqual({ 0: { value: 219665.6 }, 1: { value: 254855.52, valueSourceIndex: 1 } }); - expect(root.children[growthIndex].children[2].values).toEqual({ 0: { value: 16373481.29 }, 1: { value: 18230138.93, valueSourceIndex: 1 } }); - expect(root.children[growthIndex].children[3].values).toEqual({ 0: { value: 2585794.4 }, 1: { value: 3875087.19, valueSourceIndex: 1 } }); - expect(root.children[growthIndex].children[4].values).toEqual({ 0: { value: 6985752.48 }, 1: { value: 7881063.82, valueSourceIndex: 1 } }); - expect(root.children[growthIndex].children[5].values).toEqual({ 0: { value: 822250.324 }, 1: { value: 673989.44, valueSourceIndex: 1 } }); - - const minorIndex = root.children.findIndex(el => el.value === "Minor"); - expect(root.children[minorIndex].children[1].values).toEqual({ 0: { value: 469392.84 }, 1: { value: 494907.02, valueSourceIndex: 1 } }); - expect(root.children[minorIndex].children[2].values).toEqual({ 0: { value: 2862202 }, 1: { value: 2894830.67, valueSourceIndex: 1 } }); - expect(root.children[minorIndex].children[3].values).toEqual({ 0: { value: 16961930.3 }, 1: { value: 16632528.85, valueSourceIndex: 1 } }); - expect(root.children[minorIndex].children[4].values).toEqual({ 0: { value: 1339611 }, 1: { value: 1851610.18, valueSourceIndex: 1 } }); - expect(root.children[minorIndex].children[5].values).toEqual({ 0: { value: 638005.2 }, 1: { value: 322058.2, valueSourceIndex: 1 } }); + const root = dataView.matrix!.rows.root; + const coreIndex = root.children!.findIndex(el => el.value === "Core"); + expect(root.children![coreIndex].children![1].values).toEqual({ 0: { value: 1191435 }, 1: { value: 1419847.51, valueSourceIndex: 1 } }); + expect(root.children![coreIndex].children![2].values).toEqual({ 0: { value: 27199561.42 }, 1: { value: 35353245.96, valueSourceIndex: 1 } }); + expect(root.children![coreIndex].children![3].values).toEqual({ 0: { value: 35763040.53 }, 1: { value: 45951725.04, valueSourceIndex: 1 } }); + expect(root.children![coreIndex].children![4].values).toEqual({ 0: { value: 2507806.098 }, 1: { value: 3151651.45, valueSourceIndex: 1 } }); + expect(root.children![coreIndex].children![5].values).toEqual({ 0: { value: 374458.462 }, 1: { value: 688982.45, valueSourceIndex: 1 } }); + + const growthIndex = root.children!.findIndex(el => el.value === "Growth"); + expect(root.children![growthIndex].children![1].values).toEqual({ 0: { value: 219665.6 }, 1: { value: 254855.52, valueSourceIndex: 1 } }); + expect(root.children![growthIndex].children![2].values).toEqual({ 0: { value: 16373481.29 }, 1: { value: 18230138.93, valueSourceIndex: 1 } }); + expect(root.children![growthIndex].children![3].values).toEqual({ 0: { value: 2585794.4 }, 1: { value: 3875087.19, valueSourceIndex: 1 } }); + expect(root.children![growthIndex].children![4].values).toEqual({ 0: { value: 6985752.48 }, 1: { value: 7881063.82, valueSourceIndex: 1 } }); + expect(root.children![growthIndex].children![5].values).toEqual({ 0: { value: 822250.324 }, 1: { value: 673989.44, valueSourceIndex: 1 } }); + + const minorIndex = root.children!.findIndex(el => el.value === "Minor"); + expect(root.children![minorIndex].children![1].values).toEqual({ 0: { value: 469392.84 }, 1: { value: 494907.02, valueSourceIndex: 1 } }); + expect(root.children![minorIndex].children![2].values).toEqual({ 0: { value: 2862202 }, 1: { value: 2894830.67, valueSourceIndex: 1 } }); + expect(root.children![minorIndex].children![3].values).toEqual({ 0: { value: 16961930.3 }, 1: { value: 16632528.85, valueSourceIndex: 1 } }); + expect(root.children![minorIndex].children![4].values).toEqual({ 0: { value: 1339611 }, 1: { value: 1851610.18, valueSourceIndex: 1 } }); + expect(root.children![minorIndex].children![5].values).toEqual({ 0: { value: 638005.2 }, 1: { value: 322058.2, valueSourceIndex: 1 } }); }); it("columns should be valid", () => { - expect(dataView.matrix.columns.levels[0].sources[0].displayName).toBe("Revenue Budget"); - expect(dataView.matrix.columns.levels[0].sources[1].displayName).toBe("Total COGS"); + expect(dataView.matrix!.columns.levels[0].sources[0].displayName).toBe("Revenue Budget"); + expect(dataView.matrix!.columns.levels[0].sources[1].displayName).toBe("Total COGS"); }); it("rows should be valid", () => { - expect(dataView.matrix.rows.levels[0].sources[0].displayName).toBe("Division"); - expect(dataView.matrix.rows.levels[1].sources[0].displayName).toBe("Region"); + expect(dataView.matrix!.rows.levels[0].sources[0].displayName).toBe("Division"); + expect(dataView.matrix!.rows.levels[1].sources[0].displayName).toBe("Region"); }); }); @@ -300,7 +300,7 @@ describe("test MatrixDataViewBuilder ", () => { it("value sources should be empty", () => { - expect(dataView.matrix.valueSources).toEqual([]); + expect(dataView.matrix!.valueSources).toEqual([]); }); it("columns should be empty", () => { @@ -310,22 +310,22 @@ describe("test MatrixDataViewBuilder ", () => { }, levels: [] }; - expect(dataView.matrix.columns).toEqual(columns); + expect(dataView.matrix!.columns).toEqual(columns); }); it("rows' levels' sources should be valid", () => { - expect(dataView.matrix.rows.levels[0].sources[0].displayName).toBe("Division"); - expect(dataView.matrix.rows.levels[1].sources[0].displayName).toBe("Region"); + expect(dataView.matrix!.rows.levels[0].sources[0].displayName).toBe("Division"); + expect(dataView.matrix!.rows.levels[1].sources[0].displayName).toBe("Region"); }); it("rows' levels' depth should be valid", () => { - expect(dataView.matrix.rows.root.children[0].level).toBe(0); - expect(dataView.matrix.rows.root.children[1].level).toBe(0); - expect(dataView.matrix.rows.root.children[2].level).toBe(0); - expect(dataView.matrix.rows.root.children[0].children[0].level).toBe(1); - expect(dataView.matrix.rows.root.children[1].children[0].level).toBe(1); - expect(dataView.matrix.rows.root.children[2].children[0].level).toBe(1); + expect(dataView.matrix!.rows.root.children![0].level).toBe(0); + expect(dataView.matrix!.rows.root.children![1].level).toBe(0); + expect(dataView.matrix!.rows.root.children![2].level).toBe(0); + expect(dataView.matrix!.rows.root.children![0].children![0].level).toBe(1); + expect(dataView.matrix!.rows.root.children![1].children![0].level).toBe(1); + expect(dataView.matrix!.rows.root.children![2].children![0].level).toBe(1); }); it("root should be valid", () => { @@ -549,32 +549,32 @@ describe("test MatrixDataViewBuilder ", () => { } ] }; - expect(dataView.matrix.rows.root).toEqual(root); + expect(dataView.matrix!.rows.root).toEqual(root as any); }); it("rows should be valid", () => { const rows = ["Core", "Growth", "Minor"]; - expect(rows).toContain(dataView.matrix.rows.root.children[0].value.toString()); - expect(rows).toContain(dataView.matrix.rows.root.children[1].value.toString()); - expect(rows).toContain(dataView.matrix.rows.root.children[2].value.toString()); - - expect(dataView.matrix.rows.root.children[0].children[1].value).toBe("CENTRAL"); - expect(dataView.matrix.rows.root.children[0].children[2].value).toBe("EAST"); - expect(dataView.matrix.rows.root.children[0].children[3].value).toBe("NORTH"); - expect(dataView.matrix.rows.root.children[0].children[4].value).toBe("SOUTH"); - expect(dataView.matrix.rows.root.children[0].children[5].value).toBe("WEST"); - - expect(dataView.matrix.rows.root.children[1].children[1].value).toBe("CENTRAL"); - expect(dataView.matrix.rows.root.children[1].children[2].value).toBe("EAST"); - expect(dataView.matrix.rows.root.children[1].children[3].value).toBe("NORTH"); - expect(dataView.matrix.rows.root.children[1].children[4].value).toBe("SOUTH"); - expect(dataView.matrix.rows.root.children[1].children[5].value).toBe("WEST"); - - expect(dataView.matrix.rows.root.children[2].children[1].value).toBe("CENTRAL"); - expect(dataView.matrix.rows.root.children[2].children[2].value).toBe("EAST"); - expect(dataView.matrix.rows.root.children[2].children[3].value).toBe("NORTH"); - expect(dataView.matrix.rows.root.children[2].children[4].value).toBe("SOUTH"); - expect(dataView.matrix.rows.root.children[2].children[5].value).toBe("WEST"); + expect(rows).toContain(dataView.matrix!.rows.root.children![0].value!.toString()); + expect(rows).toContain(dataView.matrix!.rows.root.children![1].value!.toString()); + expect(rows).toContain(dataView.matrix!.rows.root.children![2].value!.toString()); + + expect(dataView.matrix!.rows.root.children![0].children![1].value).toBe("CENTRAL"); + expect(dataView.matrix!.rows.root.children![0].children![2].value).toBe("EAST"); + expect(dataView.matrix!.rows.root.children![0].children![3].value).toBe("NORTH"); + expect(dataView.matrix!.rows.root.children![0].children![4].value).toBe("SOUTH"); + expect(dataView.matrix!.rows.root.children![0].children![5].value).toBe("WEST"); + + expect(dataView.matrix!.rows.root.children![1].children![1].value).toBe("CENTRAL"); + expect(dataView.matrix!.rows.root.children![1].children![2].value).toBe("EAST"); + expect(dataView.matrix!.rows.root.children![1].children![3].value).toBe("NORTH"); + expect(dataView.matrix!.rows.root.children![1].children![4].value).toBe("SOUTH"); + expect(dataView.matrix!.rows.root.children![1].children![5].value).toBe("WEST"); + + expect(dataView.matrix!.rows.root.children![2].children![1].value).toBe("CENTRAL"); + expect(dataView.matrix!.rows.root.children![2].children![2].value).toBe("EAST"); + expect(dataView.matrix!.rows.root.children![2].children![3].value).toBe("NORTH"); + expect(dataView.matrix!.rows.root.children![2].children![4].value).toBe("SOUTH"); + expect(dataView.matrix!.rows.root.children![2].children![5].value).toBe("WEST"); }); diff --git a/test/mocks/mockIColorPaletteTest.ts b/test/mocks/mockIColorPaletteTest.ts index 0639b97..ea1d8f3 100644 --- a/test/mocks/mockIColorPaletteTest.ts +++ b/test/mocks/mockIColorPaletteTest.ts @@ -52,12 +52,23 @@ describe("MockIColorPalette", () => { expect(color.value).toBe("#01B8AA"); }); }); -}); -describe("createColorPalette", () => { - it("should return an instance of MockIColorPalette", () => { - const instance: IColorPalette = createColorPalette(); + describe("reset", () => { + it("the method should be defined", () => { + expect(colorPalette.reset).toBeDefined(); + const firstColor = colorPalette.getColor("firstKey"); + colorPalette.getColor("anotherKey"); + colorPalette.reset(); + const colorAfterReset = colorPalette.getColor("secondKey"); + expect(firstColor).toEqual(colorAfterReset); + }); + }); - expect(instance instanceof MockIColorPalette).toBeTruthy(); + describe("createColorPalette", () => { + it("should return an instance of MockIColorPalette", () => { + const instance: IColorPalette = createColorPalette(); + + expect(instance instanceof MockIColorPalette).toBeTruthy(); + }); }); }); \ No newline at end of file diff --git a/test/mocks/mockISelectionIdBuilderTest.ts b/test/mocks/mockISelectionIdBuilderTest.ts index eb5a73d..fca826b 100644 --- a/test/mocks/mockISelectionIdBuilderTest.ts +++ b/test/mocks/mockISelectionIdBuilderTest.ts @@ -1,4 +1,4 @@ -/* + /* * Power BI Visualizations * * Copyright (c) Microsoft Corporation