import { newSpy } from './unit-test-helper' ; export type Spied < T > = { [ Method in keyof T ] : jasmine . Spy ; } ; export class RouterMock { public navigateByUrl : jasmine . Spy = jasmine . createSpy ( 'navigateByUrl' ) . and . returnValue ( Promise . resolve ( ) ) ; public navigate : jasmine . Spy = jasmine . createSpy ( 'navigate' ) . and . returnValue ( Promise . resolve ( ) ) ; } export class ClipboardMock { public read : jasmine . Spy = newSpy ( 'read' , Promise . resolve ( ) ) ; public write : jasmine . Spy = newSpy ( 'write' , Promise . resolve ( ) ) ; } export class ModalControllerMock { public create : jasmine . Spy = jasmine . createSpy ( 'create' ) . and . returnValue ( Promise . resolve ( { present : jasmine . createSpy ( 'present' ) . and . returnValue ( Promise . resolve ( ) ) , onDidDismiss : jasmine . createSpy ( 'onDidDismiss' ) . and . returnValue ( Promise . resolve ( ) ) } ) ) ; public dismiss : jasmine . Spy = jasmine . createSpy ( 'dismiss' ) . and . returnValue ( Promise . resolve ( ) ) ; } export class AlertControllerMock { public create : jasmine . Spy = jasmine . createSpy ( 'create' ) . and . returnValue ( Promise . resolve ( { present : jasmine . createSpy ( 'present' ) . and . returnValue ( Promise . resolve ( ) ) , onDidDismiss : jasmine . createSpy ( 'onDidDismiss' ) . and . returnValue ( Promise . resolve ( ) ) } ) ) ; public dismiss : jasmine . Spy = jasmine . createSpy ( 'dismiss' ) . and . returnValue ( Promise . resolve ( ) ) ; } export class LoadingControllerMock { public create : jasmine . Spy = jasmine . createSpy ( 'create' ) . and . returnValue ( Promise . resolve ( { present : jasmine . createSpy ( 'present' ) . and . returnValue ( Promise . resolve ( ) ) , onDidDismiss : jasmine . createSpy ( 'dismiss' ) . and . returnValue ( Promise . resolve ( ) ) } ) ) ; } export class ToastControllerMock { public create : jasmine . Spy = jasmine . createSpy ( 'create' ) . and . returnValue ( Promise . resolve ( { present : jasmine . createSpy ( 'present' ) . and . returnValue ( Promise . resolve ( ) ) , onDidDismiss : jasmine . createSpy ( 'dismiss' ) . and . returnValue ( Promise . resolve ( ) ) } ) ) ; } export class MockActivatedRouteSnapshot { private readonly _data : any ; constructor ( data ) { this . _data = data ; } get data ( ) : any { return this . _data ; } } export class DeviceProviderMock { public isRooted : boolean = false ; public isElectron : boolean = false ; public async checkForRoot ( ) { return this . isRooted ; } public async checkForElectron ( ) { return this . isElectron ; } } export class NavParamsMock { public static params : any = { } ; public static setParams ( value ) { NavParamsMock . params = value ; } public get ( key ) { if ( NavParamsMock . params [ key ] ) { return NavParamsMock . params [ key ] ; } return undefined ; } } export class PlatformMock { public ready : jasmine . Spy = newSpy ( 'ready' , Promise . resolve ( ) ) ; public getQueryParam ( ) { return true ; } public hasFocus ( _ele ) { return true ; } public doc ( ) { return document ; } public is ( ) { console . log ( 'MOCK IS NOT CORDOVA ' ) ; return false ; } public getElementComputedStyle ( _container ) { return { paddingLeft : '10' , paddingTop : '10' , paddingRight : '10' , paddingBottom : '10' } ; } public onResize ( callback ) { return callback ; } public registerListener ( _ele , _eventName , _callback ) { return ( ) => true ; } public win ( ) { return window ; } public raf ( _callback ) { return 1 ; } public timeout ( callback , timer ) { return setTimeout ( callback , timer ) ; } public cancelTimeout ( _id ) { } public getActiveElement ( ) { return document . activeElement ; } } export class NavControllerMock { public pop ( ) { return new Promise ( ( resolve ) : void => { resolve ( ) ; } ) ; } public push ( _ctrl , _args ) { return new Promise ( ( resolve ) : void => { resolve ( ) ; } ) ; } public getActive ( ) { return { instance : { model : 'something' } } ; } public setRoot ( ) { return true ; } public registerChildNav ( _nav ) { return ; } } export class DeeplinkMock { public create : jasmine . Spy = newSpy ( 'route' , Promise . resolve ( { subscribe : jasmine . createSpy ( 'subscribe' ) . and . returnValue ( Promise . resolve ( ) ) } ) ) ; }