Merge branch 'master' of github.com:ionic-team/ionic-native
This commit is contained in:
commit
b5fe6631fe
2
scripts/docs/templates/common.template.html
vendored
2
scripts/docs/templates/common.template.html
vendored
@ -186,7 +186,7 @@ docType: "<$ doc.docType $>"
|
|||||||
<h2><a class="anchor" name="installation" href="#installation"></a>Installation</h2>
|
<h2><a class="anchor" name="installation" href="#installation"></a>Installation</h2>
|
||||||
<ol class="installation">
|
<ol class="installation">
|
||||||
<li>Install the Cordova and Ionic Native plugins:<br>
|
<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('<', '<').replace('>', '>') $><@ else @>ionic cordova plugin add <$ prop.plugin $><@ endif @>
|
||||||
$ npm install --save @ionic-native/<$ doc.npmId $>
|
$ npm install --save @ionic-native/<$ doc.npmId $>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</li>
|
</li>
|
||||||
|
69
src/@ionic-native/core/ionic-native-plugin.spec.ts
Normal file
69
src/@ionic-native/core/ionic-native-plugin.spec.ts
Normal 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');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
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 {
|
export interface ActionSheetOptions {
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import { Injectable } from '@angular/core';
|
|||||||
* constructor(private store: InAppPurchase2) { }
|
* constructor(private store: InAppPurchase2) { }
|
||||||
*
|
*
|
||||||
* ...
|
* ...
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* * @advanced
|
* * @advanced
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user