@@ -5,7 +5,7 @@ jest.mock(
5
5
) ;
6
6
7
7
const { config } = require ( 'topcoder-react-utils' ) ;
8
- const { getApiV2 , getApiV3 } = require ( '../../src/services/api' ) ;
8
+ const { getApi } = require ( '../../src/services/api' ) ;
9
9
10
10
describe ( 'Test api' , ( ) => {
11
11
const ENDPOINT = '/ENDPOINT' ;
@@ -79,43 +79,43 @@ describe('Test api', () => {
79
79
80
80
let api ;
81
81
test ( 'API v2 service works without auth token' , ( ) => {
82
- api = getApiV2 ( ) ;
82
+ api = getApi ( 'V2' ) ;
83
83
return testApi ( api , config . API . V2 ) ;
84
84
} ) ;
85
85
86
86
test ( 'API v2 service works with auth token' , ( ) => {
87
- api = getApiV2 ( 'TOKEN' ) ;
87
+ api = getApi ( 'V2' , 'TOKEN' ) ;
88
88
return testApi ( api , config . API . V2 , 'TOKEN' ) ;
89
89
} ) ;
90
90
91
91
test (
92
92
'API v2 service from the previous call is re-used, if token is the same' ,
93
- ( ) => expect ( getApiV2 ( 'TOKEN' ) ) . toBe ( api ) ,
93
+ ( ) => expect ( getApi ( 'V2' , 'TOKEN' ) ) . toBe ( api ) ,
94
94
) ;
95
95
96
96
test ( 'New API v2 service is created if token is new' , ( ) => {
97
- const api2 = getApiV2 ( 'TOKEN2' ) ;
97
+ const api2 = getApi ( 'V2' , 'TOKEN2' ) ;
98
98
expect ( api2 ) . not . toBe ( api ) ;
99
99
return testApi ( api2 , config . API . V2 , 'TOKEN2' ) ;
100
100
} ) ;
101
101
102
102
test ( 'API v3 service works without auth token' , ( ) => {
103
- api = getApiV3 ( ) ;
103
+ api = getApi ( 'V3' ) ;
104
104
return testApi ( api , config . API . V3 ) ;
105
105
} ) ;
106
106
107
107
test ( 'API v3 service works with auth token' , ( ) => {
108
- api = getApiV3 ( 'TOKEN' ) ;
108
+ api = getApi ( 'V3' , 'TOKEN' ) ;
109
109
return testApi ( api , config . API . V3 , 'TOKEN' ) ;
110
110
} ) ;
111
111
112
112
test (
113
113
'API v3 service from the previous call is re-used, if token is the same' ,
114
- ( ) => expect ( getApiV3 ( 'TOKEN' ) ) . toBe ( api ) ,
114
+ ( ) => expect ( getApi ( 'V3' , 'TOKEN' ) ) . toBe ( api ) ,
115
115
) ;
116
116
117
117
test ( 'New API v3 service is created if token is new' , ( ) => {
118
- const api2 = getApiV3 ( 'TOKEN2' ) ;
118
+ const api2 = getApi ( 'V3' , 'TOKEN2' ) ;
119
119
expect ( api2 ) . not . toBe ( api ) ;
120
120
return testApi ( api2 , config . API . V3 , 'TOKEN2' ) ;
121
121
} ) ;
0 commit comments