Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing mocks #124

Merged
merged 7 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 6.0.2
* Added missing mock functions

## 6.0.2
* Packages update
* Vulnerabilities patched
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-utils-testutils",
"version": "6.0.2",
"version": "6.0.3",
"description": "powerbi-visuals-utils-testutils",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
40 changes: 23 additions & 17 deletions src/mocks/mockVisualHost.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars*/
/*
* Power BI Visualizations
*
Expand Down Expand Up @@ -48,6 +49,8 @@ import IWebAccessService = powerbi.extensibility.IWebAccessService;

// powerbi.extensibility.visual
import IVisualHost = powerbi.extensibility.visual.IVisualHost;
import ModalDialogResult = powerbi.extensibility.visual.ModalDialogResult
import DialogOpenOptions = powerbi.extensibility.visual.DialogOpenOptions
import CustomVisualApplyCustomSortArgs = powerbi.extensibility.visual.CustomVisualApplyCustomSortArgs;
import IAcquireAADTokenService = powerbi.extensibility.IAcquireAADTokenService;

Expand All @@ -66,9 +69,8 @@ export class MockIVisualHost implements IVisualHost {
public licenseManager: IVisualLicenseManager;
public webAccessService: IWebAccessService;
public acquireAADTokenService: IAcquireAADTokenService;
public drill: (args: DrillArgs) => void;
public setCanDrill: (drillAllowed: boolean) => void;
public applyCustomSort: (args: CustomVisualApplyCustomSortArgs) => void;
public modalDialogResult: ModalDialogResult;
public hostEnv: powerbi.common.CustomVisualHostEnv = 1;

constructor(
colorPalette?: IColorPalette,
Expand All @@ -84,8 +86,9 @@ export class MockIVisualHost implements IVisualHost {
downloadService?: IDownloadService,
licenseManager?: IVisualLicenseManager,
webAccessService?: IWebAccessService,
acquireAADTokenService?: IAcquireAADTokenService
) {
acquireAADTokenService?: IAcquireAADTokenService,
modalDialogResult?: powerbi.extensibility.visual.ModalDialogResult
) {

this.colorPaletteInstance = colorPalette;
this.selectionManager = selectionManager;
Expand All @@ -101,6 +104,7 @@ export class MockIVisualHost implements IVisualHost {
this.licenseManager = licenseManager;
this.webAccessService = webAccessService;
this.acquireAADTokenService = acquireAADTokenService;
this.modalDialogResult = modalDialogResult;
}

public createSelectionIdBuilder(): ISelectionIdBuilder {
Expand All @@ -123,10 +127,7 @@ export class MockIVisualHost implements IVisualHost {
this.localeInstance.locale = language;
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public applyJsonFilter(filter: powerbi.IFilter, objectName: string, propertyName: string, action: powerbi.FilterAction) {

}
public applyJsonFilter(filter: powerbi.IFilter, objectName: string, propertyName: string, action: powerbi.FilterAction) {}

public get telemetry() {
return this.telemetryService;
Expand All @@ -136,7 +137,6 @@ export class MockIVisualHost implements IVisualHost {
return this.authenticationService;
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public persistProperties(changes: VisualObjectInstancesToPersist) { }

public get tooltipService(): ITooltipService {
Expand All @@ -163,21 +163,27 @@ export class MockIVisualHost implements IVisualHost {
return true;
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public refreshHostData() {
}
public refreshHostData() {}

public createLocalizationManager(): powerbi.extensibility.ILocalizationManager {
return {
getDisplayName: (key: string) => ""
};
}

public drill(args: DrillArgs): void {}

public switchFocusModeState: (on: boolean) => void;
public setCanDrill(drillAllowed: boolean): void {}

public hostEnv: powerbi.common.CustomVisualHostEnv = 1;
public applyCustomSort(args: CustomVisualApplyCustomSortArgs): void {}

public switchFocusModeState(on: boolean): void {}

public displayWarningIcon: (hoverText: string, detailedText: string) => void;
public displayWarningIcon(hoverText: string, detailedText: string): void {}

public openModalDialog: (dialogId: string, options?: powerbi.extensibility.visual.DialogOpenOptions, initialState?: object) => powerbi.IPromise<powerbi.extensibility.visual.ModalDialogResult>;
public openModalDialog(dialogId: string, options?: DialogOpenOptions, initialState?: object): powerbi.IPromise<ModalDialogResult> {
return new Promise<ModalDialogResult>((resolve, rejects) => {
resolve(this.modalDialogResult)
}) as any;
}
}
6 changes: 4 additions & 2 deletions src/mocks/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ import HostCapabilities = powerbi.extensibility.HostCapabilities;
import IVisualLicenseManager = powerbi.extensibility.IVisualLicenseManager;
import IWebAccessService = powerbi.extensibility.IWebAccessService;
import IAcquireAADTokenService = powerbi.extensibility.IAcquireAADTokenService;
import ModalDialogResult = powerbi.extensibility.visual.ModalDialogResult
import {MockIAcquireAADTokenService} from "./mockIAcquireAADTokenService";

// eslint-disable-next-line @typescript-eslint/ban-types
export function createVisualHost(locale?: Object, allowInteractions?: boolean, colors?: IColorInfo[], isEnabled?: boolean, displayNames?: any, token?: string): IVisualHost {
export function createVisualHost(locale?: Object, allowInteractions?: boolean, colors?: IColorInfo[], isEnabled?: boolean, displayNames?: any, token?: string, modalDialogResult?: ModalDialogResult): IVisualHost {
return new MockIVisualHost(
createColorPalette(colors),
createSelectionManager(),
Expand All @@ -77,7 +78,8 @@ export function createVisualHost(locale?: Object, allowInteractions?: boolean, c
createDownloadService(),
licenseManager(),
webAccessService(),
acquireAADTokenService()
acquireAADTokenService(),
modalDialogResult
)
}

Expand Down
Loading