import { CordovaInstance , Plugin } from './decorators' ; import { IonicNativePlugin } from './ionic-native-plugin' ; import { checkAvailability } from './plugin' ; class FT { hello ( ) { return 'world' ; } } ( window as any ) . FileTransfer = ( ) => new FT ( ) ; @ Plugin ( { plugin : 'cordova-plugin-file-transfer' , pluginRef : 'FileTransfer' , repo : '' , pluginName : 'FileTransfer' } ) export class FileTransfer extends IonicNativePlugin { create ( ) { let instance ; if ( checkAvailability ( FileTransfer . getPluginRef ( ) , null , FileTransfer . getPluginName ( ) ) === true ) { instance = new ( FileTransfer . getPlugin ( ) ) ( ) ; } return new FileTransferObject ( instance ) ; } } export class FileTransferObject { constructor ( public _objectInstance ) { console . info ( 'Creating a new FileTransferObject with instance: ' , _objectInstance ) ; } @ CordovaInstance ( { sync : true } ) hello ( ) { return ; } } describe ( 'Mock FileTransfer Plugin' , ( ) => { let plugin , instance ; beforeAll ( ( ) => { plugin = new FileTransfer ( ) ; instance = plugin . create ( ) ; } ) ; it ( 'should create a new FileTransfer plugin instance' , ( ) => { expect ( plugin instanceof FileTransfer ) . toBeTruthy ( ) ; } ) ; it ( 'should create new FileTransferObject instance' , ( ) => { expect ( instance instanceof FileTransferObject ) . toBeTruthy ( ) ; } ) ; it ( 'FileTransferObject instance should have _objectInstance property' , ( ) => { expect ( instance . _objectInstance ) . toBeDefined ( ) ; } ) ; it ( 'FileTransferObject.hello should return world' , ( ) => { console . info ( 'instance hello is' , instance . hello ( ) ) ; expect ( instance . hello ( ) ) . toEqual ( 'world' ) ; } ) ; } ) ;