1- import * as sinon from 'sinon' ;
21import { expect } from 'chai' ;
2+ import { of , throwError } from 'rxjs' ;
3+ import * as sinon from 'sinon' ;
34import { RpcProxy } from '../../context/rpc-proxy' ;
4- import { RpcExceptionsHandler } from '../../exceptions/rpc-exceptions-handler' ;
55import { RpcException } from '../../exceptions/rpc-exception' ;
6- import { Observable , of } from 'rxjs ' ;
6+ import { RpcExceptionsHandler } from '../../exceptions/rpc-exceptions-handler ' ;
77
88describe ( 'RpcProxy' , ( ) => {
99 let routerProxy : RpcProxy ;
@@ -18,10 +18,7 @@ describe('RpcProxy', () => {
1818
1919 describe ( 'create' , ( ) => {
2020 it ( 'should method return thunk' , async ( ) => {
21- const proxy = await routerProxy . create (
22- async data => of ( true ) ,
23- handler ,
24- ) ;
21+ const proxy = await routerProxy . create ( async data => of ( true ) , handler ) ;
2522 expect ( typeof proxy === 'function' ) . to . be . true ;
2623 } ) ;
2724
@@ -33,5 +30,26 @@ describe('RpcProxy', () => {
3330 await proxy ( null ) ;
3431 expectation . verify ( ) ;
3532 } ) ;
33+
34+ it ( 'should attach "catchError" operator when observable was returned' , async ( ) => {
35+ const expectation = handlerMock . expects ( 'handle' ) . once ( ) ;
36+ const proxy = routerProxy . create ( async ( client , data ) => {
37+ return throwError ( new RpcException ( 'test' ) ) ;
38+ } , handler ) ;
39+ ( await proxy ( null , null ) ) . subscribe ( null , ( ) => expectation . verify ( ) ) ;
40+ } ) ;
41+ } ) ;
42+
43+ describe ( 'isObservable' , ( ) => {
44+ describe ( 'when observable' , ( ) => {
45+ it ( 'should return true' , ( ) => {
46+ expect ( routerProxy . isObservable ( of ( 'test' ) ) ) . to . be . true ;
47+ } ) ;
48+ } ) ;
49+ describe ( 'when not observable' , ( ) => {
50+ it ( 'should return false' , ( ) => {
51+ expect ( routerProxy . isObservable ( { } ) ) . to . be . false ;
52+ } ) ;
53+ } ) ;
3654 } ) ;
3755} ) ;
0 commit comments