UNPKG

@web-atoms/core

Version:
131 lines 4.71 kB
import { App } from "../App"; import { AtomUri } from "../core/AtomUri"; import { IDisposable, INameValuePairs, INameValues } from "../core/types"; import { AtomViewModel } from "../view-model/AtomViewModel"; import { AtomWindowViewModel } from "../view-model/AtomWindowViewModel"; import { NavigationService } from "./NavigationService"; export interface IWindowRegistration { windowType: string; action: (vm: AtomViewModel) => any; } export declare class MockConfirmViewModel extends AtomWindowViewModel { message: string; title: string; } /** * Mock of WindowService for unit tests * @export * @class MockWindowService * @extends {WindowService} */ export declare class MockNavigationService extends NavigationService { title: string; private windowStack; private history; private mLocation; /** * Gets current location of browser, this does not return * actual location but it returns values of browser location. * This is done to provide mocking behavior for unit testing. * * @readonly * @type {AtomLocation} * @memberof BrowserService */ get location(): AtomUri; set location(v: AtomUri); constructor(app: App); refresh(): void; /** * Navigate current browser to given url. * @param {string} url * @memberof BrowserService */ navigate(url: string): void; back(): void; /** * Internal usage * @param {string} msg * @param {string} [title] * @returns {Promise<any>} * @memberof MockWindowService */ alert(msg: string, title?: string): Promise<any>; /** * Internal usage * @param {string} msg * @param {string} [title] * @returns {Promise<boolean>} * @memberof MockWindowService */ confirm(msg: string, title?: string): Promise<boolean>; openPage<T>(pageName: string, p?: INameValuePairs): Promise<T>; notify(message: string, title?: string): Promise<void>; /** * Internal usage * @template T * @param {string} c * @param {AtomViewModel} vm * @returns {Promise<T>} * @memberof MockWindowService */ openTestWindow<T>(c: string | AtomUri, p?: INameValues): Promise<T>; /** * Call this method before any method that should expect an alert. * You can add many alerts, but each expected alert will only be called * once. * @param {string} msg * @returns {IDisposable} * @memberof MockWindowService */ expectAlert(msg: string): IDisposable; /** * Call this method before any method that should expect a notification. * You can add many alerts, but each expected alert will only be called * once. * @param {string} msg * @returns {IDisposable} * @memberof MockWindowService */ expectNotification(msg: string): IDisposable; /** * Call this method before any method that should expect a confirm. * You can add many confirms, but each expected confirm will only be called * once. * @param {string} msg * @param {(vm:MockConfirmViewModel) => boolean} action * @returns {IDisposable} * @memberof MockWindowService */ expectConfirm(msg: string, action: (vm: MockConfirmViewModel) => boolean): IDisposable; /** * Call this method before any method that should expect a window of given type. * Each window will only be used once and return value in windowAction will be * resolved in promise created by openWindow call. * @template TViewModel * @param {string} windowType * @param {(vm:TViewModel) => any} windowAction * @param {number} [maxDelay=10000] * @returns {IDisposable} * @memberof MockWindowService */ expectPopup<TViewModel extends AtomViewModel>(popupType: string, windowAction: (vm: TViewModel) => any): IDisposable; /** * Call this method before any method that should expect a window of given type. * Each window will only be used once and return value in windowAction will be * resolved in promise created by openWindow call. * @template TViewModel * @param {string} windowType * @param {(vm:TViewModel) => any} windowAction * @param {number} [maxDelay=10000] * @returns {IDisposable} * @memberof MockWindowService */ expectWindow<TViewModel extends AtomViewModel>(windowType: string, windowAction: (vm: TViewModel) => any): IDisposable; removeRegistration(r: IWindowRegistration): void; assert(): void; protected registerForPopup(): void; protected forceRemove(view: any): void; protected openWindow<T>(url: AtomUri): Promise<T>; } //# sourceMappingURL=MockNavigationService.d.ts.map