File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ describe('uri-generator.generate-uri', () => {
1010 } ) ;
1111 } ) ;
1212
13+ context ( 'when no URI is provided' , ( ) => {
14+ it ( 'handles host' , ( ) => {
15+ expect ( generateUri ( { _ : [ ] , host : 'localhost' } ) ) . to . equal ( 'mongodb://localhost:27017' )
16+ } ) ;
17+ it ( 'handles port' , ( ) => {
18+ expect ( generateUri ( { _ : [ ] , port : '27018' } ) ) . to . equal ( 'mongodb://127.0.0.1:27018' )
19+ } ) ;
20+ } ) ;
21+
1322 context ( 'when a full URI is provided' , ( ) => {
1423 context ( 'when no additional options are provided' , ( ) => {
1524 const uri = 'mongodb://192.0.0.1:27018/foo' ;
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ function validateConflicts(options: CliOptions): any {
6161 *
6262 * @returns {string } The host.
6363 */
64- function generateHost ( options : CliOptions = { } ) : string {
64+ function generateHost ( options : CliOptions ) : string {
6565 return options . host ? options . host : DEFAULT_HOST ;
6666}
6767
@@ -72,7 +72,8 @@ function generateHost(options: CliOptions = {}): string {
7272 *
7373 * @returns {string } The port.
7474 */
75- function generatePort ( options : CliOptions = { } ) : string {
75+ function generatePort ( options : CliOptions ) : string {
76+ console . log ( `in generatePort, options=${ options . port } ` ) ;
7677 return options . port ? options . port : DEFAULT_PORT ;
7778}
7879
@@ -97,7 +98,7 @@ function generateUri(options: CliOptions): string {
9798
9899 // There is no URI provided, use default 127.0.0.1:27017
99100 if ( ! uri ) {
100- return `${ Scheme . Mongo } ${ generateHost ( ) } :${ generatePort ( ) } ` ;
101+ return `${ Scheme . Mongo } ${ generateHost ( options ) } :${ generatePort ( options ) } ` ;
101102 }
102103
103104 // A mongodb:// or mongodb+srv:// URI is provided, treat as correct.
You can’t perform that action at this time.
0 commit comments