diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html index 0c2ad365c..475c43d10 100644 --- a/scripts/docs/templates/common.template.html +++ b/scripts/docs/templates/common.template.html @@ -186,7 +186,7 @@ docType: "<$ doc.docType $>"

Installation

  1. Install the Cordova and Ionic Native plugins:
    -
    $ <@ if prop.install @><$ prop.install $><@ else @>ionic cordova plugin add <$ prop.plugin $><@ endif @>
    +    
    $ <@ if prop.install @><$ prop.install | replace('<', '<').replace('>', '>') $><@ else @>ionic cordova plugin add <$ prop.plugin $><@ endif @>
     $ npm install --save @ionic-native/<$ doc.npmId $>
     
  2. diff --git a/src/@ionic-native/core/ionic-native-plugin.spec.ts b/src/@ionic-native/core/ionic-native-plugin.spec.ts new file mode 100644 index 000000000..69df51ce8 --- /dev/null +++ b/src/@ionic-native/core/ionic-native-plugin.spec.ts @@ -0,0 +1,69 @@ +// This is to verify that new (FileTransfer.getPlugin)() works + +import { Plugin, CordovaInstance } from './decorators'; +import { checkAvailability } from './plugin'; +import { IonicNativePlugin } from './ionic-native-plugin'; + +class FT { + hello(): string { + 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(): FileTransferObject { + let instance: any; + if (checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) { + instance = new (FileTransfer.getPlugin())(); + } + return new FileTransferObject(instance); + } +} + +export class FileTransferObject { + + constructor(public _objectInstance: any) { + console.info('Creating a new FileTransferObject with instance: ', _objectInstance); + } + + @CordovaInstance({ sync: true }) + hello(): string { return; } + +} + +describe('Mock FileTransfer Plugin', () => { + + let plugin: FileTransfer, + instance: FileTransferObject; + + 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'); + }); + +}); diff --git a/src/@ionic-native/plugins/action-sheet/index.ts b/src/@ionic-native/plugins/action-sheet/index.ts index ea8e5f1d9..28c33d829 100644 --- a/src/@ionic-native/plugins/action-sheet/index.ts +++ b/src/@ionic-native/plugins/action-sheet/index.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Cordova, Plugin, CordovaProperty, IonicNativePlugin } from '@ionic-native/core'; +import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; export interface ActionSheetOptions { diff --git a/src/@ionic-native/plugins/in-app-purchase-2/index.ts b/src/@ionic-native/plugins/in-app-purchase-2/index.ts index 6780e92e9..46436d642 100644 --- a/src/@ionic-native/plugins/in-app-purchase-2/index.ts +++ b/src/@ionic-native/plugins/in-app-purchase-2/index.ts @@ -13,6 +13,7 @@ import { Injectable } from '@angular/core'; * constructor(private store: InAppPurchase2) { } * * ... + * ``` * * * @advanced *