@@ -120,70 +120,68 @@ describe('Bolt V4 API', () => {
120
120
} )
121
121
} )
122
122
123
- it ( 'should fail if connecting to a non-existing database' , done => {
123
+ it ( 'should fail if connecting to a non-existing database' , async ( ) => {
124
124
if ( ! databaseSupportsBoltV4 ( ) ) {
125
- done ( )
126
125
return
127
126
}
128
127
129
128
const neoSession = driver . session ( { db : 'testdb' } )
130
129
131
- neoSession
132
- . run ( 'RETURN 1' )
133
- . then ( result => {
134
- done . fail ( 'Failure expected' )
135
- } )
136
- . catch ( error => {
137
- expect ( error . code ) . toContain ( 'DatabaseNotFound' )
138
- done ( )
139
- } )
140
- . finally ( ( ) => neoSession . close ( ) )
130
+ try {
131
+ await neoSession . run ( 'RETURN 1' )
132
+
133
+ fail ( 'failure expected' )
134
+ } catch ( error ) {
135
+ expect ( error . code ) . toContain ( 'DatabaseNotFound' )
136
+ } finally {
137
+ neoSession . close ( )
138
+ }
141
139
} )
142
140
143
141
describe ( 'neo4j database' , ( ) => {
144
- it ( 'should be able to create a node' , done => {
142
+ it ( 'should be able to create a node' , async ( ) => {
145
143
if ( ! databaseSupportsBoltV4 ( ) ) {
146
- done ( )
147
144
return
148
145
}
149
146
150
147
const neoSession = driver . session ( { db : 'neo4j' } )
151
148
152
- neoSession
153
- . run ( 'CREATE (n { db: $db }) RETURN n.db' , { db : 'neo4j' } )
154
- . then ( result => {
155
- expect ( result . records . length ) . toBe ( 1 )
156
- expect ( result . records [ 0 ] . get ( 'n.db' ) ) . toBe ( 'neo4j' )
157
- done ( )
158
- } )
159
- . catch ( error => {
160
- done . fail ( error )
161
- } )
162
- . finally ( ( ) => neoSession . close ( ) )
149
+ try {
150
+ const result = await session . run (
151
+ 'CREATE (n { db: $db }) RETURN n.db' ,
152
+ { db : 'neo4j' }
153
+ )
154
+
155
+ expect ( result . records . length ) . toBe ( 1 )
156
+ expect ( result . records [ 0 ] . get ( 'n.db' ) ) . toBe ( 'neo4j' )
157
+ } finally {
158
+ neoSession . close ( )
159
+ }
163
160
} )
164
161
165
- it ( 'should be able to connect single instance using neo4j scheme' , done => {
162
+ it ( 'should be able to connect single instance using neo4j scheme' , async ( ) => {
166
163
if ( ! databaseSupportsBoltV4 ( ) ) {
167
- done ( )
168
164
return
169
165
}
170
166
171
- const neoDriver = neo4j . driver ( 'neo4j://localhost' , sharedNeo4j . authToken )
167
+ const neoDriver = neo4j . driver (
168
+ 'neo4j://localhost' ,
169
+ sharedNeo4j . authToken
170
+ )
172
171
const neoSession = driver . session ( { db : 'neo4j' } )
173
172
174
- neoSession
175
- . run ( 'CREATE (n { db: $db }) RETURN n.db' , { db : 'neo4j' } )
176
- . then ( result => {
177
- expect ( result . records . length ) . toBe ( 1 )
178
- expect ( result . records [ 0 ] . get ( 'n.db' ) ) . toBe ( 'neo4j' )
179
- done ( )
180
- } )
181
- . catch ( error => {
182
- done . fail ( error )
183
- } )
184
- . finally ( ( ) => neoSession . close ( ) )
185
-
186
- neoDriver . close ( )
173
+ try {
174
+ const result = await session . run (
175
+ 'CREATE (n { db: $db }) RETURN n.db' ,
176
+ { db : 'neo4j' }
177
+ )
178
+
179
+ expect ( result . records . length ) . toBe ( 1 )
180
+ expect ( result . records [ 0 ] . get ( 'n.db' ) ) . toBe ( 'neo4j' )
181
+ } finally {
182
+ neoSession . close ( )
183
+ neoDriver . close ( )
184
+ }
187
185
} )
188
186
} )
189
187
} )
0 commit comments