File tree Expand file tree Collapse file tree 6 files changed +28
-13
lines changed Expand file tree Collapse file tree 6 files changed +28
-13
lines changed Original file line number Diff line number Diff line change 3
3
> A high-level library for interacting with DADI API
4
4
5
5
[ ![ npm (scoped)] ( https://img.shields.io/npm/v/@dadi/api-wrapper.svg?maxAge=10800&style=flat-square )] ( https://www.npmjs.com/package/@dadi/api-wrapper )
6
- ![ coverage] ( https://img.shields.io/badge/coverage-93 %25-brightgreen.svg?style=flat-square )
6
+ ![ coverage] ( https://img.shields.io/badge/coverage-91 %25-brightgreen.svg?style=flat-square )
7
7
[ ![ Build Status] ( https://travis-ci.org/dadi/api-wrapper.svg?branch=master )] ( https://travis-ci.org/dadi/api-wrapper )
8
8
[ ![ JavaScript Style Guide] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square )] ( http://standardjs.com/ )
9
9
[ ![ semantic-release] ( https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square )] ( https://github.com/semantic-release/semantic-release )
Original file line number Diff line number Diff line change @@ -21,14 +21,6 @@ const APIWrapper = function (options) {
21
21
path : __dirname + '/.wallet/token.' + this . _slugify ( options . uri + options . port ) + '.' + this . _slugify ( options . credentials . clientId ) + '.json'
22
22
}
23
23
}
24
-
25
- // Initialise logger
26
- this . logger = require ( '@dadi/logger' )
27
- this . logger . init ( {
28
- enabled : true ,
29
- filename : 'api-wrapper' ,
30
- level : this . options . debug ? 'info' : 'warn'
31
- } )
32
24
}
33
25
34
26
APIWrapper . prototype = new APIWrapperCore ( )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const debug = require ( 'debug' ) ( 'api-wrapper' )
3
4
const passport = require ( '@dadi/passport' )
4
5
const request = require ( 'request-promise' )
5
6
6
7
module . exports = function ( APIWrapper ) {
7
8
/**
8
- * Logs a message. Overrides the basic log mechanism with DADI Logger
9
+ * Logs a debug message to the console when running with `DEBUG=*`.
9
10
*
10
11
* @param {String } message
11
12
* @return undefined
12
13
* @api private
13
14
*/
14
15
APIWrapper . prototype . _log = function ( message ) {
15
- this . logger . info ( message )
16
+ debug ( message )
16
17
}
17
18
18
19
/**
Original file line number Diff line number Diff line change 12
12
"license" : " GPL" ,
13
13
"dependencies" : {
14
14
"@dadi/api-wrapper-core" : " 1.x.0" ,
15
- "@dadi/logger" : " ^1.1.3" ,
16
15
"@dadi/passport" : " ^1.2.0" ,
16
+ "debug" : " ^2.6.1" ,
17
17
"query-string" : " ^4.1.0" ,
18
18
"request-promise" : " ^2.0.1" ,
19
19
"standard" : " *"
Original file line number Diff line number Diff line change @@ -355,4 +355,26 @@ describe('Terminators', function (done) {
355
355
} )
356
356
} )
357
357
} )
358
+
359
+ describe ( 'getCollections' , function ( ) {
360
+ afterEach ( function ( ) {
361
+ apiWrapper . prototype . _buildURL . restore ( )
362
+ } )
363
+
364
+ it ( 'should call buildUrl with {collections:true}' , function ( ) {
365
+ var host = options . uri + ':' + options . port
366
+ var urlPath = '/api/collections'
367
+ var scope = nock ( host ) . get ( urlPath ) . reply ( 200 )
368
+
369
+ sinon . stub ( apiWrapper . prototype , '_buildURL' , function ( ) {
370
+ var args = arguments [ 0 ]
371
+ args . should . eql ( { collections :true } )
372
+ return this . options . uri + ':' + this . options . port + '/api/collections'
373
+ } )
374
+
375
+ return wrapper . getCollections ( ) . then ( ) . catch ( ( err ) => {
376
+ throw err
377
+ } )
378
+ } )
379
+ } )
358
380
} )
You can’t perform that action at this time.
0 commit comments