11import 'core-js' ;
2- import { Plugin , Cordova , CordovaProperty , CordovaCheck , CordovaInstance , InstanceProperty } from './decorators' ;
2+
3+ import { Observable } from 'rxjs/Observable' ;
4+
5+ import {
6+ Cordova ,
7+ CordovaCheck ,
8+ CordovaInstance ,
9+ CordovaProperty ,
10+ InstanceProperty ,
11+ Plugin
12+ } from './decorators' ;
313import { IonicNativePlugin } from './ionic-native-plugin' ;
414import { ERR_CORDOVA_NOT_AVAILABLE , ERR_PLUGIN_NOT_INSTALLED } from './plugin' ;
5- import { Observable } from 'rxjs/Observable' ;
615
716declare const window : any ;
817
918class TestObject {
10-
1119 constructor ( public _objectInstance : any ) { }
1220
13- @InstanceProperty
14- name : string ;
21+ @InstanceProperty name : string ;
1522
1623 @CordovaInstance ( { sync : true } )
17- pingSync ( ) : string { return ; }
24+ pingSync ( ) : string {
25+ return ;
26+ }
1827
1928 @CordovaInstance ( )
20- ping ( ) : Promise < any > { return ; }
21-
29+ ping ( ) : Promise < any > {
30+ return ;
31+ }
2232}
2333
2434@Plugin ( {
@@ -29,15 +39,17 @@ class TestObject {
2939 platforms : [ 'Android' , 'iOS' ]
3040} )
3141class TestPlugin extends IonicNativePlugin {
32-
33- @CordovaProperty
34- name : string ;
42+ @CordovaProperty name : string ;
3543
3644 @Cordova ( { sync : true } )
37- pingSync ( ) : string { return ; }
45+ pingSync ( ) : string {
46+ return ;
47+ }
3848
3949 @Cordova ( )
40- ping ( ) : Promise < string > { return ; }
50+ ping ( ) : Promise < string > {
51+ return ;
52+ }
4153
4254 @CordovaCheck ( )
4355 customPing ( ) : Promise < string > {
@@ -51,14 +63,17 @@ class TestPlugin extends IonicNativePlugin {
5163 @Cordova ( {
5264 destruct : true
5365 } )
54- destructPromise ( ) : Promise < any > { return ; }
66+ destructPromise ( ) : Promise < any > {
67+ return ;
68+ }
5569
5670 @Cordova ( {
5771 destruct : true ,
5872 observable : true
5973 } )
60- destructObservable ( ) : Observable < any > { return ; }
61-
74+ destructObservable ( ) : Observable < any > {
75+ return ;
76+ }
6277}
6378
6479function definePlugin ( ) {
@@ -78,7 +93,6 @@ function definePlugin() {
7893}
7994
8095describe ( 'Regular Decorators' , ( ) => {
81-
8296 let plugin : TestPlugin ;
8397
8498 beforeEach ( ( ) => {
@@ -87,7 +101,6 @@ describe('Regular Decorators', () => {
87101 } ) ;
88102
89103 describe ( 'Plugin' , ( ) => {
90-
91104 it ( 'should set pluginName' , ( ) => {
92105 expect ( TestPlugin . getPluginName ( ) ) . toEqual ( 'TestPlugin' ) ;
93106 } ) ;
@@ -103,17 +116,16 @@ describe('Regular Decorators', () => {
103116 it ( 'should return supported platforms' , ( ) => {
104117 expect ( TestPlugin . getSupportedPlatforms ( ) ) . toEqual ( [ 'Android' , 'iOS' ] ) ;
105118 } ) ;
106-
107119 } ) ;
108120
109121 describe ( 'Cordova' , ( ) => {
110-
111122 it ( 'should do a sync function' , ( ) => {
112123 expect ( plugin . pingSync ( ) ) . toEqual ( 'pong' ) ;
113124 } ) ;
114125
115126 it ( 'should do an async function' , ( done : Function ) => {
116- plugin . ping ( )
127+ plugin
128+ . ping ( )
117129 . then ( res => {
118130 expect ( res ) . toEqual ( 'pong' ) ;
119131 done ( ) ;
@@ -125,39 +137,31 @@ describe('Regular Decorators', () => {
125137 } ) ;
126138
127139 it ( 'should throw plugin_not_installed error' , ( done : Function ) => {
128-
129140 delete window . testPlugin ;
130141 window . cordova = true ;
131142
132143 expect ( < any > plugin . pingSync ( ) ) . toEqual ( ERR_PLUGIN_NOT_INSTALLED ) ;
133144
134- plugin . ping ( )
135- . catch ( e => {
136- expect ( e ) . toEqual ( ERR_PLUGIN_NOT_INSTALLED . error ) ;
137- delete window . cordova ;
138- done ( ) ;
139- } ) ;
140-
145+ plugin . ping ( ) . catch ( e => {
146+ expect ( e ) . toEqual ( ERR_PLUGIN_NOT_INSTALLED . error ) ;
147+ delete window . cordova ;
148+ done ( ) ;
149+ } ) ;
141150 } ) ;
142151
143152 it ( 'should throw cordova_not_available error' , ( done : Function ) => {
144-
145153 delete window . testPlugin ;
146154
147155 expect ( < any > plugin . pingSync ( ) ) . toEqual ( ERR_CORDOVA_NOT_AVAILABLE ) ;
148156
149- plugin . ping ( )
150- . catch ( e => {
151- expect ( e ) . toEqual ( ERR_CORDOVA_NOT_AVAILABLE . error ) ;
152- done ( ) ;
153- } ) ;
154-
157+ plugin . ping ( ) . catch ( e => {
158+ expect ( e ) . toEqual ( ERR_CORDOVA_NOT_AVAILABLE . error ) ;
159+ done ( ) ;
160+ } ) ;
155161 } ) ;
156-
157162 } ) ;
158163
159164 describe ( 'CordovaProperty' , ( ) => {
160-
161165 it ( 'should return property value' , ( ) => {
162166 expect ( plugin . name ) . toEqual ( 'John Smith' ) ;
163167 } ) ;
@@ -166,101 +170,79 @@ describe('Regular Decorators', () => {
166170 plugin . name = 'value2' ;
167171 expect ( plugin . name ) . toEqual ( 'value2' ) ;
168172 } ) ;
169-
170173 } ) ;
171174
172175 describe ( 'CordovaCheck' , ( ) => {
173-
174- it ( 'should run the method when plugin exists' , ( done ) => {
175- plugin . customPing ( )
176- . then ( res => {
177- expect ( res ) . toEqual ( 'pong' ) ;
178- done ( ) ;
179- } ) ;
176+ it ( 'should run the method when plugin exists' , done => {
177+ plugin . customPing ( ) . then ( res => {
178+ expect ( res ) . toEqual ( 'pong' ) ;
179+ done ( ) ;
180+ } ) ;
180181 } ) ;
181182
182- it ( 'shouldnt run the method when plugin doesnt exist' , ( done ) => {
183+ it ( 'shouldnt run the method when plugin doesnt exist' , done => {
183184 delete window . testPlugin ;
184185 window . cordova = true ;
185- plugin . customPing ( )
186- . catch ( e => {
187- expect ( e ) . toEqual ( ERR_PLUGIN_NOT_INSTALLED . error ) ;
188- done ( ) ;
189- } ) ;
186+ plugin . customPing ( ) . catch ( e => {
187+ expect ( e ) . toEqual ( ERR_PLUGIN_NOT_INSTALLED . error ) ;
188+ done ( ) ;
189+ } ) ;
190190 } ) ;
191-
192191 } ) ;
193192
194193 describe ( 'CordovaOptions' , ( ) => {
195-
196194 describe ( 'destruct' , ( ) => {
197-
198- it ( 'should destruct values returned by a Promise' , ( done ) => {
199- plugin . destructPromise ( )
200- . then ( ( args : any [ ] ) => {
201- expect ( args ) . toEqual ( [ 'hello' , 'world' ] ) ;
202- done ( ) ;
203- } ) ;
195+ it ( 'should destruct values returned by a Promise' , done => {
196+ plugin . destructPromise ( ) . then ( ( args : any [ ] ) => {
197+ expect ( args ) . toEqual ( [ 'hello' , 'world' ] ) ;
198+ done ( ) ;
199+ } ) ;
204200 } ) ;
205201
206- it ( 'should destruct values returned by an Observable' , ( done ) => {
207- plugin . destructObservable ( )
208- . subscribe ( ( args : any [ ] ) => {
209- expect ( args ) . toEqual ( [ 'hello' , 'world' ] ) ;
210- done ( ) ;
211- } ) ;
202+ it ( 'should destruct values returned by an Observable' , done => {
203+ plugin . destructObservable ( ) . subscribe ( ( args : any [ ] ) => {
204+ expect ( args ) . toEqual ( [ 'hello' , 'world' ] ) ;
205+ done ( ) ;
206+ } ) ;
212207 } ) ;
213-
214208 } ) ;
215-
216209 } ) ;
217-
218210} ) ;
219211
220212describe ( 'Instance Decorators' , ( ) => {
221-
222- let instance : TestObject ,
223- plugin : TestPlugin ;
213+ let instance : TestObject , plugin : TestPlugin ;
224214
225215 beforeEach ( ( ) => {
226216 definePlugin ( ) ;
227217 plugin = new TestPlugin ( ) ;
228218 instance = plugin . create ( ) ;
229219 } ) ;
230220
231- describe ( 'Instance plugin' , ( ) => {
232-
233-
234-
235- } ) ;
221+ describe ( 'Instance plugin' , ( ) => { } ) ;
236222
237223 describe ( 'CordovaInstance' , ( ) => {
238-
239- it ( 'should call instance async method' , ( done ) => {
240- instance . ping ( )
241- . then ( r => {
242- expect ( r ) . toEqual ( 'pong' ) ;
243- done ( ) ;
244- } ) ;
224+ it ( 'should call instance async method' , done => {
225+ instance . ping ( ) . then ( r => {
226+ expect ( r ) . toEqual ( 'pong' ) ;
227+ done ( ) ;
228+ } ) ;
245229 } ) ;
246230
247231 it ( 'should call instance sync method' , ( ) => {
248232 expect ( instance . pingSync ( ) ) . toEqual ( 'pong' ) ;
249233 } ) ;
250234
251235 it ( 'shouldnt call instance method when _objectInstance is undefined' , ( ) => {
252-
253236 delete instance . _objectInstance ;
254- instance . ping ( )
237+ instance
238+ . ping ( )
255239 . then ( r => {
256240 expect ( r ) . toBeUndefined ( ) ;
257241 } )
258242 . catch ( e => {
259243 expect ( e ) . toBeUndefined ( ) ;
260244 } ) ;
261-
262245 } ) ;
263-
264246 } ) ;
265247
266248 describe ( 'InstanceProperty' , ( ) => {
@@ -273,5 +255,4 @@ describe('Instance Decorators', () => {
273255 expect ( instance . name ) . toEqual ( 'John Cena' ) ;
274256 } ) ;
275257 } ) ;
276-
277258} ) ;
0 commit comments