@@ -118,6 +118,23 @@ describe('Bolt V4 API', () => {
118
118
done ( )
119
119
} )
120
120
} )
121
+
122
+ it ( 'should return db.name as null in result summary' , async ( ) => {
123
+ if ( databaseSupportsBoltV4 ( ) ) {
124
+ return
125
+ }
126
+
127
+ const session = driver . session ( )
128
+
129
+ try {
130
+ const result = await session . readTransaction ( tx => tx . run ( 'RETURN 1' ) )
131
+
132
+ expect ( result . summary . database ) . toBeTruthy ( )
133
+ expect ( result . summary . database . name ) . toBeNull ( )
134
+ } finally {
135
+ session . close ( )
136
+ }
137
+ } )
121
138
} )
122
139
123
140
it ( 'should fail if connecting to a non-existing database' , async ( ) => {
@@ -138,7 +155,17 @@ describe('Bolt V4 API', () => {
138
155
}
139
156
} )
140
157
158
+ describe ( 'default database' , function ( ) {
159
+ it ( 'should return database name in summary' , async ( ) => {
160
+ await testDatabaseNameInSummary ( null )
161
+ } )
162
+ } )
163
+
141
164
describe ( 'neo4j database' , ( ) => {
165
+ it ( 'should return database name in summary' , async ( ) => {
166
+ await testDatabaseNameInSummary ( 'neo4j' )
167
+ } )
168
+
142
169
it ( 'should be able to create a node' , async ( ) => {
143
170
if ( ! databaseSupportsBoltV4 ( ) ) {
144
171
return
@@ -186,6 +213,27 @@ describe('Bolt V4 API', () => {
186
213
} )
187
214
} )
188
215
216
+ async function testDatabaseNameInSummary ( dbname ) {
217
+ if ( ! databaseSupportsBoltV4 ( ) ) {
218
+ return
219
+ }
220
+
221
+ const neoSession = dbname
222
+ ? driver . session ( { db : dbname } )
223
+ : driver . session ( )
224
+
225
+ try {
226
+ const result = await neoSession . run ( 'CREATE (n { id: $id }) RETURN n' , {
227
+ id : 5
228
+ } )
229
+
230
+ expect ( result . summary . database ) . toBeTruthy ( )
231
+ expect ( result . summary . database . name ) . toBe ( dbname || 'neo4j' )
232
+ } finally {
233
+ neoSession . close ( )
234
+ }
235
+ }
236
+
189
237
function expectBoltV4NotSupportedError ( error ) {
190
238
expect (
191
239
error . message . indexOf (
0 commit comments