Merge branch 'master' of github.com:ionic-team/ionic-native

This commit is contained in:
Ibby Hadeed 2017-07-15 14:29:59 -04:00
commit b5fe6631fe
No known key found for this signature in database
GPG Key ID: 22EFE47A3DDBDB5C
4 changed files with 72 additions and 2 deletions

View File

@ -186,7 +186,7 @@ docType: "<$ doc.docType $>"
<h2><a class="anchor" name="installation" href="#installation"></a>Installation</h2>
<ol class="installation">
<li>Install the Cordova and Ionic Native plugins:<br>
<pre><code class="nohighlight">$ <@ if prop.install @><$ prop.install $><@ else @>ionic cordova plugin add <$ prop.plugin $><@ endif @>
<pre><code class="nohighlight">$ <@ if prop.install @><$ prop.install | replace('<', '&lt;').replace('>', '&gt;') $><@ else @>ionic cordova plugin add <$ prop.plugin $><@ endif @>
$ npm install --save @ionic-native/<$ doc.npmId $>
</code></pre>
</li>

View File

@ -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');
});
});

View File

@ -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 {

View File

@ -13,6 +13,7 @@ import { Injectable } from '@angular/core';
* constructor(private store: InAppPurchase2) { }
*
* ...
* ```
*
* * @advanced
*