Skip to content

Commit 3f1fb81

Browse files
committed
Fix errors in bolt-v4 tests
1 parent ab498c4 commit 3f1fb81

File tree

1 file changed

+39
-41
lines changed

1 file changed

+39
-41
lines changed

test/bolt-v4.test.js

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -120,70 +120,68 @@ describe('Bolt V4 API', () => {
120120
})
121121
})
122122

123-
it('should fail if connecting to a non-existing database', done => {
123+
it('should fail if connecting to a non-existing database', async () => {
124124
if (!databaseSupportsBoltV4()) {
125-
done()
126125
return
127126
}
128127

129128
const neoSession = driver.session({ db: 'testdb' })
130129

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+
}
141139
})
142140

143141
describe('neo4j database', () => {
144-
it('should be able to create a node', done => {
142+
it('should be able to create a node', async () => {
145143
if (!databaseSupportsBoltV4()) {
146-
done()
147144
return
148145
}
149146

150147
const neoSession = driver.session({ db: 'neo4j' })
151148

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+
}
163160
})
164161

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 () => {
166163
if (!databaseSupportsBoltV4()) {
167-
done()
168164
return
169165
}
170166

171-
const neoDriver = neo4j.driver('neo4j://localhost', sharedNeo4j.authToken)
167+
const neoDriver = neo4j.driver(
168+
'neo4j://localhost',
169+
sharedNeo4j.authToken
170+
)
172171
const neoSession = driver.session({ db: 'neo4j' })
173172

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+
}
187185
})
188186
})
189187
})

0 commit comments

Comments
 (0)