This repository was archived by the owner on Mar 28, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +190
-6
lines changed Expand file tree Collapse file tree 4 files changed +190
-6
lines changed Original file line number Diff line number Diff line change 38
38
"@babel/preset-env" : " ^7.7.7" ,
39
39
"@rollup/plugin-commonjs" : " ^11.0.0" ,
40
40
"@rollup/plugin-node-resolve" : " ^6.0.0" ,
41
+ "babel-eslint" : " ^10.0.3" ,
41
42
"babel-jest" : " ^24.9.0" ,
42
43
"babel-polyfill" : " ^6.26.0" ,
43
44
"coveralls" : " ^3.0.7" ,
51
52
"prettier" : " ^1.19.1" ,
52
53
"rollup" : " ^1.27.14" ,
53
54
"rollup-plugin-babel" : " ^4.3.3" ,
54
- "rollup-plugin-uglify" : " ^6.0.4"
55
+ "rollup-plugin-uglify" : " ^6.0.4" ,
56
+ "sinon" : " ^8.0.1"
55
57
},
56
58
"lint-staged" : {
57
59
"test/**/*.js" : " eslint" ,
Original file line number Diff line number Diff line change 1
- const index = require ( "../index" ) ;
1
+ import { config } from "../index" ;
2
2
3
3
describe ( "Exported methods" , ( ) => {
4
4
it ( "should include config" , ( ) => {
5
- expect ( index . config ) . toBeDefined ( ) ;
5
+ expect ( config ) . toBeDefined ( ) ;
6
6
} ) ;
7
7
} ) ;
Original file line number Diff line number Diff line change 1
- const { config } = require ( "../../src/config" ) ;
1
+ import sinon from "sinon" ;
2
+ import { instances } from "@data-provider/core" ;
3
+
4
+ import config from "../../src/config" ;
5
+ import TAG from "../../src/tag" ;
2
6
3
7
describe ( "config method" , ( ) => {
4
- it ( "should be defined" , ( ) => {
5
- expect ( config ) . toBeDefined ( ) ;
8
+ const BASE_URL = "http://localhost:3001" ;
9
+ const API_PATH = "/foo-admin" ;
10
+
11
+ let sandbox ;
12
+ beforeAll ( ( ) => {
13
+ sandbox = sinon . createSandbox ( ) ;
14
+ sandbox . spy ( instances . getByTag ( TAG ) , "config" ) ;
15
+ } ) ;
16
+
17
+ afterAll ( ( ) => {
18
+ sandbox . restore ( ) ;
19
+ } ) ;
20
+
21
+ it ( "should set baseUrl in admin-api-client tagged providers" , ( ) => {
22
+ config ( {
23
+ baseUrl : BASE_URL
24
+ } ) ;
25
+ expect ( instances . getByTag ( TAG ) . config . getCall ( 0 ) . args [ 0 ] . baseUrl ) . toEqual ( `${ BASE_URL } /admin` ) ;
26
+ } ) ;
27
+
28
+ it ( "should set apiPath in admin-api-client tagged providers" , ( ) => {
29
+ config ( {
30
+ baseUrl : BASE_URL ,
31
+ apiPath : API_PATH
32
+ } ) ;
33
+ expect ( instances . getByTag ( TAG ) . config . getCall ( 1 ) . args [ 0 ] . baseUrl ) . toEqual (
34
+ `${ BASE_URL } ${ API_PATH } `
35
+ ) ;
6
36
} ) ;
7
37
} ) ;
You can’t perform that action at this time.
0 commit comments