1- import { expect } from 'chai' ;
1+ import chai , { expect } from 'chai' ;
2+ import chaiAsPromised from 'chai-as-promised' ;
3+
4+ chai . use ( chaiAsPromised ) ;
5+
26import getConnectExtraInfo from './connect-info' ;
37import { ConnectionString } from 'mongodb-connection-string-url' ;
48
@@ -42,18 +46,15 @@ describe('getConnectInfo', function () {
4246 ok : 1 ,
4347 } ;
4448
45- const ATLAS_VERSION = {
46- atlasVersion : '20210330.0.0.1617063608' ,
47- gitVersion : '8f7e5bdde713391e8123a463895bb7fb660a5ffd' ,
48- } ;
49+ const ATLAS_VERSION = '20210330.0.0.1617063608' ;
4950
5051 const ATLAS_URI =
5152 'mongodb+srv://admin:[email protected] /admin' ; 5253
5354 const ATLAS_URI_WITH_AUTH =
5455 'mongodb+srv://admin:[email protected] /admin?authMechanism=PLAIN&authSource=%24external' ; 5556
56- it ( 'reports on an enterprise version >=3.2 of mongodb with credentials' , function ( ) {
57+ it ( 'reports on an enterprise version >=3.2 of mongodb with credentials' , async function ( ) {
5758 const output = {
5859 is_atlas : true ,
5960 is_atlas_url : true ,
@@ -64,7 +65,7 @@ describe('getConnectInfo', function () {
6465 auth_type : 'PLAIN' ,
6566 is_data_federation : false ,
6667 is_stream : false ,
67- dl_version : null ,
68+ dl_version : undefined ,
6869 atlas_version : '20210330.0.0.1617063608' ,
6970 is_genuine : true ,
7071 non_genuine_server_name : 'mongodb' ,
@@ -74,18 +75,18 @@ describe('getConnectInfo', function () {
7475 uri : ATLAS_URI_WITH_AUTH ,
7576 is_local_atlas : false ,
7677 } ;
77- expect (
78+ await expect (
7879 getConnectExtraInfo ( {
7980 connectionString : new ConnectionString ( ATLAS_URI_WITH_AUTH ) ,
80- buildInfo : BUILD_INFO ,
81- atlasVersion : ATLAS_VERSION ,
81+ buildInfo : Promise . resolve ( BUILD_INFO ) ,
82+ atlasVersion : Promise . resolve ( ATLAS_VERSION ) ,
8283 resolvedHostname : 'test-data-sets-00-02-a011bb.mongodb.net' ,
83- isLocalAtlas : false ,
84+ isLocalAtlas : Promise . resolve ( false ) ,
8485 } )
85- ) . to . deep . equal ( output ) ;
86+ ) . to . eventually . deep . equal ( output ) ;
8687 } ) ;
8788
88- it ( 'reports on an enterprise version >=3.2 of mongodb with no credentials' , function ( ) {
89+ it ( 'reports on an enterprise version >=3.2 of mongodb with no credentials' , async function ( ) {
8990 const output = {
9091 is_atlas : true ,
9192 is_atlas_url : true ,
@@ -96,7 +97,7 @@ describe('getConnectInfo', function () {
9697 auth_type : undefined ,
9798 is_data_federation : false ,
9899 is_stream : false ,
99- dl_version : null ,
100+ dl_version : undefined ,
100101 atlas_version : '20210330.0.0.1617063608' ,
101102 is_genuine : true ,
102103 non_genuine_server_name : 'mongodb' ,
@@ -106,18 +107,18 @@ describe('getConnectInfo', function () {
106107 uri : ATLAS_URI ,
107108 is_local_atlas : false ,
108109 } ;
109- expect (
110+ await expect (
110111 getConnectExtraInfo ( {
111112 connectionString : new ConnectionString ( ATLAS_URI ) ,
112- buildInfo : BUILD_INFO ,
113- atlasVersion : ATLAS_VERSION ,
113+ buildInfo : Promise . resolve ( BUILD_INFO ) ,
114+ atlasVersion : Promise . resolve ( ATLAS_VERSION ) ,
114115 resolvedHostname : 'test-data-sets-00-02-a011bb.mongodb.net' ,
115- isLocalAtlas : false ,
116+ isLocalAtlas : Promise . resolve ( false ) ,
116117 } )
117- ) . to . deep . equal ( output ) ;
118+ ) . to . eventually . deep . equal ( output ) ;
118119 } ) ;
119120
120- it ( 'reports correct information when a stream uri is passed' , function ( ) {
121+ it ( 'reports correct information when a stream uri is passed' , async function ( ) {
121122 const streamUri =
122123 'mongodb://atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net/' ;
123124 const output = {
@@ -130,8 +131,8 @@ describe('getConnectInfo', function () {
130131 auth_type : undefined ,
131132 is_data_federation : false ,
132133 is_stream : true ,
133- dl_version : null ,
134- atlas_version : null ,
134+ dl_version : undefined ,
135+ atlas_version : undefined ,
135136 is_genuine : true ,
136137 is_local_atlas : false ,
137138 non_genuine_server_name : 'mongodb' ,
@@ -140,19 +141,19 @@ describe('getConnectInfo', function () {
140141 server_os : 'osx' ,
141142 uri : streamUri ,
142143 } ;
143- expect (
144+ await expect (
144145 getConnectExtraInfo ( {
145146 connectionString : new ConnectionString ( streamUri ) ,
146- buildInfo : BUILD_INFO ,
147- atlasVersion : null ,
147+ buildInfo : Promise . resolve ( BUILD_INFO ) ,
148+ atlasVersion : Promise . resolve ( undefined ) ,
148149 resolvedHostname :
149150 'atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net' ,
150- isLocalAtlas : false ,
151+ isLocalAtlas : Promise . resolve ( false ) ,
151152 } )
152- ) . to . deep . equal ( output ) ;
153+ ) . to . eventually . deep . equal ( output ) ;
153154 } ) ;
154155
155- it ( 'reports correct information when an empty uri is passed' , function ( ) {
156+ it ( 'reports correct information when an empty uri is passed' , async function ( ) {
156157 const output = {
157158 is_atlas : false ,
158159 is_atlas_url : false ,
@@ -163,8 +164,8 @@ describe('getConnectInfo', function () {
163164 auth_type : undefined ,
164165 is_data_federation : false ,
165166 is_stream : false ,
166- dl_version : null ,
167- atlas_version : null ,
167+ dl_version : undefined ,
168+ atlas_version : undefined ,
168169 is_genuine : true ,
169170 non_genuine_server_name : 'mongodb' ,
170171 server_arch : 'x86_64' ,
@@ -173,17 +174,17 @@ describe('getConnectInfo', function () {
173174 uri : '' ,
174175 is_local_atlas : true ,
175176 } ;
176- expect (
177+ await expect (
177178 getConnectExtraInfo ( {
178- buildInfo : BUILD_INFO ,
179- atlasVersion : null ,
179+ buildInfo : Promise . resolve ( BUILD_INFO ) ,
180+ atlasVersion : Promise . resolve ( undefined ) ,
180181 resolvedHostname : 'localhost' ,
181- isLocalAtlas : true ,
182+ isLocalAtlas : Promise . resolve ( true ) ,
182183 } )
183- ) . to . deep . equal ( output ) ;
184+ ) . to . eventually . deep . equal ( output ) ;
184185 } ) ;
185186
186- it ( 'does not fail when buildInfo is unavailable' , function ( ) {
187+ it ( 'does not fail when buildInfo is unavailable' , async function ( ) {
187188 const output = {
188189 is_atlas : false ,
189190 is_atlas_url : false ,
@@ -194,22 +195,22 @@ describe('getConnectInfo', function () {
194195 auth_type : undefined ,
195196 is_data_federation : false ,
196197 is_stream : false ,
197- dl_version : null ,
198- atlas_version : null ,
198+ dl_version : undefined ,
199+ atlas_version : undefined ,
199200 is_genuine : true ,
200201 non_genuine_server_name : 'mongodb' ,
201- server_arch : null ,
202202 node_version : process . version ,
203- server_os : null ,
203+ server_arch : undefined ,
204+ server_os : undefined ,
204205 uri : '' ,
205206 is_local_atlas : false ,
206207 } ;
207- expect (
208+ await expect (
208209 getConnectExtraInfo ( {
209- buildInfo : null ,
210- atlasVersion : null ,
211- isLocalAtlas : false ,
210+ buildInfo : Promise . resolve ( null ) ,
211+ atlasVersion : Promise . resolve ( undefined ) ,
212+ isLocalAtlas : Promise . resolve ( false ) ,
212213 } )
213- ) . to . deep . equal ( output ) ;
214+ ) . to . eventually . deep . equal ( output ) ;
214215 } ) ;
215216} ) ;
0 commit comments