@@ -55,25 +55,39 @@ describe('Api', function() {
5555
5656 it ( 'should set it\'s config.url correctly when passed correct url and not passed version' , function ( ) {
5757 var api = streamApiService . getInstance ( { url : 'https://foo' } ) ;
58- expect ( api . config . url )
58+ expect ( api . baseUrl )
5959 . toBe ( 'https://foo/attask/api' ) ;
6060 } ) ;
6161
6262 it ( 'should set it\'s config.url when passed valid url and version unsupported' , function ( ) {
6363 var api = streamApiService . getInstance ( { url : 'https://foo' , version : 'unsupported' } ) ;
64- expect ( api . config . url )
64+ expect ( api . baseUrl )
6565 . toBe ( 'https://foo/attask/api-unsupported' ) ;
6666 } ) ;
6767
6868 it ( 'should set it\'s config.url when passed valid url and version internal' , function ( ) {
6969 var api = streamApiService . getInstance ( { url : 'https://foo' , version : 'internal' } ) ;
70- expect ( api . config . url )
70+ expect ( api . baseUrl )
7171 . toBe ( 'https://foo/attask/api-internal' ) ;
7272 } ) ;
7373
7474 it ( 'should set it\'s config.url when passed valid url and version number' , function ( ) {
7575 var api = streamApiService . getInstance ( { url : 'https://foo' , version : '5.0' } ) ;
76- expect ( api . config . url )
76+ expect ( api . baseUrl )
7777 . toBe ( 'https://foo/attask/api/v5.0' ) ;
7878 } ) ;
79+
80+ it ( 'should return the same object on each getInstance regardless of passed config and version' , function ( ) {
81+ var api1 = streamApiService . getInstance ( { url : 'https://foo' , version : '5.0' } ) ;
82+ var api2 = streamApiService . getInstance ( { url : 'https://bar' , version : '4.0' } ) ;
83+ expect ( api1 ) . toBe ( api2 ) ;
84+ } ) ;
85+
86+ it ( 'should return new Api object when requested new' , function ( ) {
87+ var api1 = streamApiService . getInstance ( { url : 'https://foo' , version : '5.0' } ) ;
88+ var api2 = streamApiService . getInstance ( { url : 'https://bar' , version : '4.0' } , true ) ;
89+ expect ( api1 ) . not . toBe ( api2 ) ;
90+ } ) ;
91+
92+
7993} ) ;
0 commit comments