@@ -3,25 +3,30 @@ import * as projectApi from '../../project';
3
3
import { Client } from '../client' ;
4
4
5
5
describe ( 'Client' , ( ) => {
6
+ const authKey = {
7
+ keyId : 'someid' ,
8
+ keySecret : 'somesecret'
9
+ }
10
+
6
11
describe ( 'new instance' , ( ) => {
7
12
it ( 'should create http client based on production Surix API url' , ( ) => {
8
13
const spy = jest . spyOn ( api , 'getApiClient' ) ;
9
- new Client ( ) ;
14
+ new Client ( { ... authKey } ) ;
10
15
expect ( spy . mock . calls ) . toMatchSnapshot ( ) ;
11
16
spy . mockRestore ( ) ;
12
17
} ) ;
13
18
describe ( 'when environment is not set to production' , ( ) => {
14
19
it ( 'should create http client based on staging url' , ( ) => {
15
20
const spy = jest . spyOn ( api , 'getApiClient' ) ;
16
- new Client ( { environment : 'staging' } ) ;
21
+ new Client ( { environment : 'staging' , ... authKey } ) ;
17
22
expect ( spy . mock . calls ) . toMatchSnapshot ( ) ;
18
23
spy . mockRestore ( ) ;
19
24
} ) ;
20
25
} ) ;
21
26
it ( 'should override baseUrl if baseUrl option is provided' , ( ) => {
22
27
const spy = jest . spyOn ( api , 'getApiClient' ) ;
23
28
const baseUrl = 'http://mydomain.com/api' ;
24
- new Client ( { baseUrl } ) ;
29
+ new Client ( { baseUrl, ... authKey } ) ;
25
30
expect ( spy . mock . calls ) . toMatchSnapshot ( ) ;
26
31
spy . mockRestore ( ) ;
27
32
} ) ;
@@ -32,7 +37,7 @@ describe('Client', () => {
32
37
const apiClient = { } ;
33
38
jest . spyOn ( api , 'getApiClient' ) . mockReturnValue ( apiClient ) ;
34
39
jest . spyOn ( projectApi , 'getProjectApi' ) ;
35
- const client = new Client ( ) ;
40
+ const client = new Client ( { ... authKey } ) ;
36
41
client . project ( 'id' ) ;
37
42
expect ( projectApi . getProjectApi ) . toHaveBeenCalledWith ( 'id' , apiClient ) ;
38
43
} ) ;
0 commit comments