@@ -55,25 +55,39 @@ describe('Api', function() {
55
55
56
56
it ( 'should set it\'s config.url correctly when passed correct url and not passed version' , function ( ) {
57
57
var api = streamApiService . getInstance ( { url : 'https://foo' } ) ;
58
- expect ( api . config . url )
58
+ expect ( api . baseUrl )
59
59
. toBe ( 'https://foo/attask/api' ) ;
60
60
} ) ;
61
61
62
62
it ( 'should set it\'s config.url when passed valid url and version unsupported' , function ( ) {
63
63
var api = streamApiService . getInstance ( { url : 'https://foo' , version : 'unsupported' } ) ;
64
- expect ( api . config . url )
64
+ expect ( api . baseUrl )
65
65
. toBe ( 'https://foo/attask/api-unsupported' ) ;
66
66
} ) ;
67
67
68
68
it ( 'should set it\'s config.url when passed valid url and version internal' , function ( ) {
69
69
var api = streamApiService . getInstance ( { url : 'https://foo' , version : 'internal' } ) ;
70
- expect ( api . config . url )
70
+ expect ( api . baseUrl )
71
71
. toBe ( 'https://foo/attask/api-internal' ) ;
72
72
} ) ;
73
73
74
74
it ( 'should set it\'s config.url when passed valid url and version number' , function ( ) {
75
75
var api = streamApiService . getInstance ( { url : 'https://foo' , version : '5.0' } ) ;
76
- expect ( api . config . url )
76
+ expect ( api . baseUrl )
77
77
. toBe ( 'https://foo/attask/api/v5.0' ) ;
78
78
} ) ;
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
+
79
93
} ) ;
0 commit comments