File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ var defaultOpts = function() {
6363} ;
6464
6565var Modem = function ( opts ) {
66- if ( ! opts ) {
66+ if ( ! opts || ( Object . keys ( opts ) . length === 0 && opts . constructor === Object ) ) {
6767 opts = defaultOpts ( ) ;
6868 }
6969
Original file line number Diff line number Diff line change 11var assert = require ( 'assert' ) ;
22var Modem = require ( '../lib/modem' ) ;
3+ var defaultSocketPath = require ( 'os' ) . type ( ) === 'Windows_NT' ? '//./pipe/docker_engine' : '/var/run/docker.sock' ;
34
45describe ( 'Modem' , function ( ) {
56 beforeEach ( function ( ) {
67 delete process . env . DOCKER_HOST ;
78 } ) ;
89
9- it ( 'should default to /var/run/docker.sock ' , function ( ) {
10+ it ( 'should default to default socket path ' , function ( ) {
1011 var modem = new Modem ( ) ;
1112 assert . ok ( modem . socketPath ) ;
12- assert . strictEqual ( modem . socketPath , '/var/run/docker.sock' ) ;
13+ assert . strictEqual ( modem . socketPath , defaultSocketPath ) ;
14+ } ) ;
15+
16+ it ( 'should default to default socket path with empty object argument' , function ( ) {
17+ var modem = new Modem ( { } ) ;
18+ assert . ok ( modem . socketPath ) ;
19+ assert . strictEqual ( modem . socketPath , defaultSocketPath ) ;
20+ } ) ;
21+
22+ it ( 'should not default to default socket path with non-empty object argument' , function ( ) {
23+ var modem = new Modem ( { a : 'b' } ) ;
24+ assert . strictEqual ( modem . socketPath , undefined ) ;
1325 } ) ;
1426
1527 it ( 'should allow DOCKER_HOST=unix:///path/to/docker.sock' , function ( ) {
You can’t perform that action at this time.
0 commit comments