/* Copyright (c) 2022 Betim Beja and Shko Online LLC Licensed under the MIT license. */ import { stub } from 'sinon'; import type { SinonStub } from 'sinon'; type AlertDialogStrings = ComponentFramework.NavigationApi.AlertDialogStrings; type AlertDialogOptions = ComponentFramework.NavigationApi.AlertDialogOptions; type ConfirmDialogStrings = ComponentFramework.NavigationApi.ConfirmDialogStrings; type ConfirmDialogOptions = ComponentFramework.NavigationApi.ConfirmDialogOptions; type ConfirmDialogResponse = ComponentFramework.NavigationApi.ConfirmDialogResponse; export class NavigationMock implements ComponentFramework.Navigation { openAlertDialog: SinonStub<[alertStrings: AlertDialogStrings, options?: AlertDialogOptions], Promise>; openConfirmDialog: SinonStub< [confirmStrings: ConfirmDialogStrings, options?: ConfirmDialogOptions], Promise >; openErrorDialog: SinonStub<[options: ComponentFramework.NavigationApi.ErrorDialogOptions], Promise>; openFile: SinonStub< [file: ComponentFramework.FileObject, options?: ComponentFramework.NavigationApi.OpenFileOptions], Promise >; openForm: SinonStub< [options: ComponentFramework.NavigationApi.EntityFormOptions, parameters?: { [key: string]: string }], Promise >; openUrl: SinonStub<[url: string, options?: ComponentFramework.NavigationApi.OpenUrlOptions], void>; openWebResource: SinonStub< [name: string, options?: ComponentFramework.NavigationApi.OpenWebResourceOptions, data?: string], void >; constructor() { this.openAlertDialog = stub(); this.openAlertDialog.callsFake( ( alertStrings: ComponentFramework.NavigationApi.AlertDialogStrings, options?: ComponentFramework.NavigationApi.AlertDialogOptions, ) => { return Promise.resolve(); }, ); this.openConfirmDialog = stub(); this.openConfirmDialog.callsFake( ( confirmStrings: ComponentFramework.NavigationApi.ConfirmDialogStrings, options?: ComponentFramework.NavigationApi.ConfirmDialogOptions, ) => { return Promise.resolve({ confirmed: true, }); }, ); this.openErrorDialog = stub(); this.openFile = stub(); this.openForm = stub(); this.openUrl = stub(); this.openWebResource = stub(); } }