11import { chai } from 'meteor/practicalmeteor:chai' ;
22import { sinon } from 'meteor/practicalmeteor:sinon' ;
3- import { MeteorObservable , ObservableMeteorSubscription } from " angular2-meteor" ;
4- import { Observable } from " rxjs" ;
3+ import { MeteorObservable , ObservableMeteorSubscription } from ' angular2-meteor' ;
4+ import { Observable } from ' rxjs' ;
55
66const expect = chai . expect ;
77
88describe ( 'MeteorObservable' , function ( ) {
9- describe ( " call" , function ( ) {
9+ describe ( ' call' , function ( ) {
1010
11- it ( " Should return RxJS Observable when using ' call'" , function ( ) {
12- let returnValue = MeteorObservable . call ( " testMethod" ) ;
11+ it ( ' Should return RxJS Observable when using " call"' , function ( ) {
12+ let returnValue = MeteorObservable . call ( ' testMethod' ) ;
1313 expect ( returnValue instanceof Observable ) . to . equal ( true ) ;
1414 } ) ;
1515
16- it ( " Should NOT run the actual ' call' method without subscribing to the result" , function ( ) {
17- let spy = sinon . spy ( Meteor , " call" ) ;
18- MeteorObservable . call ( " testMethod" ) ;
16+ it ( ' Should NOT run the actual " call" method without subscribing to the result' , function ( ) {
17+ let spy = sinon . spy ( Meteor , ' call' ) ;
18+ MeteorObservable . call ( ' testMethod' ) ;
1919 expect ( spy . called ) . to . equal ( false ) ;
2020 spy . restore ( ) ;
2121 } ) ;
2222
23- it ( " Should run the actual ' call' method when subscribing to the result" , function ( ) {
24- let spy = sinon . spy ( Meteor , " call" ) ;
25- let subscriptionHandler = MeteorObservable . call ( " testMethod" ) . subscribe ( function ( ) { } ) ;
23+ it ( ' Should run the actual " call" method when subscribing to the result' , function ( ) {
24+ let spy = sinon . spy ( Meteor , ' call' ) ;
25+ let subscriptionHandler = MeteorObservable . call ( ' testMethod' ) . subscribe ( function ( ) { } ) ;
2626 expect ( spy . calledOnce ) . to . equal ( true ) ;
2727 spy . restore ( ) ;
2828 subscriptionHandler . unsubscribe ( ) ;
2929 } ) ;
3030
31- it ( " Should trigger the RxJS Observable ' next' callback when got the server response" , function ( done ) {
31+ it ( ' Should trigger the RxJS Observable " next" callback when got the server response' , function ( done ) {
3232 let spy = sinon . spy ( ) ;
33- let subscriptionHandler = MeteorObservable . call ( " testMethod" ) . subscribe ( ( serverResponse ) => {
33+ let subscriptionHandler = MeteorObservable . call ( ' testMethod' ) . subscribe ( ( serverResponse ) => {
3434 spy ( ) ;
3535 expect ( spy . callCount ) . to . equal ( 1 ) ;
36- expect ( serverResponse ) . to . equal ( " TEST_VALUE" ) ;
36+ expect ( serverResponse ) . to . equal ( ' TEST_VALUE' ) ;
3737 subscriptionHandler . unsubscribe ( ) ;
3838 done ( ) ;
3939 } ) ;
4040 } ) ;
4141
42- it ( " Should trigger the RxJS Observable 'complete' callback when got the server response" , function ( done ) {
42+ it ( ' Should trigger the RxJS Observable "error" callback when got the server error' , function ( done ) {
4343 let spy = sinon . spy ( ) ;
44- let subscriptionHandler = MeteorObservable . call ( "testMethod" ) . subscribe ( function ( ) { } , function ( ) { } , ( ) => {
45- spy ( ) ;
46- expect ( spy . callCount ) . to . equal ( 1 ) ;
47- subscriptionHandler . unsubscribe ( ) ;
48- done ( ) ;
49- } ) ;
50- } ) ;
51-
52- it ( "Should trigger the RxJS Observable 'error' callback when got the server error" , function ( done ) {
53- let spy = sinon . spy ( ) ;
54- let subscriptionHandler = MeteorObservable . call ( "NON_EXISTING_METHOD" ) . subscribe ( function ( ) { } , ( e ) => {
44+ let subscriptionHandler = MeteorObservable . call ( 'NON_EXISTING_METHOD' ) . subscribe ( function ( ) { } , ( e ) => {
5545 spy ( ) ;
5646 expect ( spy . callCount ) . to . equal ( 1 ) ;
5747 expect ( e instanceof Meteor . Error ) . to . equal ( true ) ;
@@ -61,46 +51,46 @@ describe('MeteorObservable', function () {
6151 } ) ;
6252 } ) ;
6353
64- describe ( " subscribe" , function ( ) {
65- it ( " Should return RxJS Observable when using ' subscribe'" , function ( ) {
66- let returnValue = MeteorObservable . subscribe ( " test" ) ;
54+ describe ( ' subscribe' , function ( ) {
55+ it ( ' Should return RxJS Observable when using " subscribe"' , function ( ) {
56+ let returnValue = MeteorObservable . subscribe ( ' test' ) ;
6757 expect ( returnValue instanceof Observable ) . to . equal ( true ) ;
6858 } ) ;
6959
70- it ( " Should NOT run the actual ' subscribe' method without subscribing to the result" , function ( ) {
71- let spy = sinon . spy ( Meteor , " subscribe" ) ;
72- MeteorObservable . subscribe ( " test" ) ;
60+ it ( ' Should NOT run the actual " subscribe" method without subscribing to the result' , function ( ) {
61+ let spy = sinon . spy ( Meteor , ' subscribe' ) ;
62+ MeteorObservable . subscribe ( ' test' ) ;
7363 expect ( spy . called ) . to . equal ( false ) ;
7464 spy . restore ( ) ;
7565 } ) ;
7666
77- it ( " Should run the actual ' subscribe' method when subscribing to the result" , function ( ) {
78- let spy = sinon . spy ( Meteor , " subscribe" ) ;
79- let subscriptionHandler = MeteorObservable . subscribe ( " test" ) . subscribe ( function ( ) { } ) ;
67+ it ( ' Should run the actual " subscribe" method when subscribing to the result' , function ( ) {
68+ let spy = sinon . spy ( Meteor , ' subscribe' ) ;
69+ let subscriptionHandler = MeteorObservable . subscribe ( ' test' ) . subscribe ( function ( ) { } ) ;
8070 expect ( spy . called ) . to . equal ( true ) ;
8171 spy . restore ( ) ;
8272 subscriptionHandler . unsubscribe ( ) ;
8373 } ) ;
8474
85- it ( " Should call RxJS Observable ' next' callback when subscription is ready" , function ( done ) {
75+ it ( ' Should call RxJS Observable " next" callback when subscription is ready' , function ( done ) {
8676 let spy = sinon . spy ( ) ;
8777
88- let subscriptionHandler = MeteorObservable . subscribe ( " test" ) . subscribe ( ( ) => {
78+ let subscriptionHandler = MeteorObservable . subscribe ( ' test' ) . subscribe ( ( ) => {
8979 spy ( ) ;
9080 expect ( spy . callCount ) . to . equal ( 1 ) ;
9181 subscriptionHandler . unsubscribe ( ) ;
9282 done ( ) ;
9383 } ) ;
9484 } ) ;
9585
96- it ( " Should stop the Meteor subscription when unsubscribing to the RxJS Observable" , function ( done ) {
86+ it ( ' Should stop the Meteor subscription when unsubscribing to the RxJS Observable' , function ( done ) {
9787 function getSubscriptionsCount ( ) {
9888 return Object . keys ( ( < any > Meteor ) . default_connection . _subscriptions ) . length ;
9989 }
10090
10191 let baseSubscriptionsCount = getSubscriptionsCount ( ) ;
10292
103- let subscriptionHandler = MeteorObservable . subscribe ( " test" ) . subscribe ( ( ) => {
93+ let subscriptionHandler = MeteorObservable . subscribe ( ' test' ) . subscribe ( ( ) => {
10494 expect ( getSubscriptionsCount ( ) ) . to . equal ( baseSubscriptionsCount + 1 ) ;
10595 subscriptionHandler . unsubscribe ( ) ;
10696 expect ( getSubscriptionsCount ( ) ) . to . equal ( baseSubscriptionsCount ) ;
@@ -109,15 +99,15 @@ describe('MeteorObservable', function () {
10999 } ) ;
110100
111101
112- it ( " Should stop the Meteor subscription when calling stop of the Observable" , function ( done ) {
102+ it ( ' Should stop the Meteor subscription when calling stop of the Observable' , function ( done ) {
113103 function getSubscriptionsCount ( ) {
114104 return Object . keys ( ( < any > Meteor ) . default_connection . _subscriptions ) . length ;
115105 }
116106
117107 let baseSubscriptionsCount = getSubscriptionsCount ( ) ;
118108
119- let obs : ObservableMeteorSubscription < any > = MeteorObservable . subscribe ( " test" ) ;
120- let subscriptionHandler = obs . subscribe ( ( ) => {
109+ let obs : ObservableMeteorSubscription < any > = MeteorObservable . subscribe ( ' test' ) ;
110+ obs . subscribe ( ( ) => {
121111 expect ( getSubscriptionsCount ( ) ) . to . equal ( baseSubscriptionsCount + 1 ) ;
122112 obs . stop ( ) ;
123113 expect ( getSubscriptionsCount ( ) ) . to . equal ( baseSubscriptionsCount ) ;
0 commit comments