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 33> A high-level library for interacting with DADI API
44
55[ ![ 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 )
77[ ![ Build Status] ( https://travis-ci.org/dadi/api-wrapper.svg?branch=master )] ( https://travis-ci.org/dadi/api-wrapper )
88[ ![ JavaScript Style Guide] ( https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square )] ( http://standardjs.com/ )
99[ ![ 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) {
2121 path : __dirname + '/.wallet/token.' + this . _slugify ( options . uri + options . port ) + '.' + this . _slugify ( options . credentials . clientId ) + '.json'
2222 }
2323 }
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- } )
3224}
3325
3426APIWrapper . prototype = new APIWrapperCore ( )
Original file line number Diff line number Diff line change 11'use strict'
22
3+ const debug = require ( 'debug' ) ( 'api-wrapper' )
34const passport = require ( '@dadi/passport' )
45const request = require ( 'request-promise' )
56
67module . exports = function ( APIWrapper ) {
78 /**
8- * Logs a message. Overrides the basic log mechanism with DADI Logger
9+ * Logs a debug message to the console when running with `DEBUG=*`.
910 *
1011 * @param {String } message
1112 * @return undefined
1213 * @api private
1314 */
1415 APIWrapper . prototype . _log = function ( message ) {
15- this . logger . info ( message )
16+ debug ( message )
1617 }
1718
1819 /**
Original file line number Diff line number Diff line change 1212 "license" : " GPL" ,
1313 "dependencies" : {
1414 "@dadi/api-wrapper-core" : " 1.x.0" ,
15- "@dadi/logger" : " ^1.1.3" ,
1615 "@dadi/passport" : " ^1.2.0" ,
16+ "debug" : " ^2.6.1" ,
1717 "query-string" : " ^4.1.0" ,
1818 "request-promise" : " ^2.0.1" ,
1919 "standard" : " *"
Original file line number Diff line number Diff line change @@ -355,4 +355,26 @@ describe('Terminators', function (done) {
355355 } )
356356 } )
357357 } )
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+ } )
358380} )
You can’t perform that action at this time.
0 commit comments