1919
2020import neo4j from '../src'
2121import sharedNeo4j from './internal/shared-neo4j'
22- import { ServerVersion , VERSION_4_0_0 } from '../src/internal/server-version'
2322
2423describe ( '#integration result summary' , ( ) => {
25- let driver , session , serverVersion
24+ describe ( 'default driver' , ( ) => {
25+ let driver , session
2626
27- beforeEach ( async ( ) => {
28- driver = neo4j . driver ( 'bolt://localhost' , sharedNeo4j . authToken )
29- session = driver . session ( )
27+ beforeEach ( done => {
28+ driver = neo4j . driver ( 'bolt://localhost' , sharedNeo4j . authToken )
29+ session = driver . session ( )
3030
31- serverVersion = await sharedNeo4j . cleanupAndGetVersion ( driver )
31+ session . run ( 'MATCH (n) DETACH DELETE n' ) . then ( done )
32+ } )
33+
34+ afterEach ( ( ) => {
35+ driver . close ( )
36+ } )
37+
38+ it ( 'should get result summary' , done => {
39+ verifySummary ( session , done )
40+ } )
41+
42+ it ( 'should get plan from summary' , done => {
43+ verifyPlan ( session , done )
44+ } )
45+
46+ it ( 'should get profile from summary' , done => {
47+ verifyProfile ( session , done )
48+ } )
49+
50+ it ( 'should get notifications from summary' , done => {
51+ verifyNotifications ( session , 'EXPLAIN MATCH (n), (m) RETURN n, m' , done )
52+ } )
3253 } )
3354
34- afterEach ( async ( ) => {
35- await driver . close ( )
55+ describe ( 'driver with lossless integers disabled' , ( ) => {
56+ let driver , session
57+
58+ beforeEach ( done => {
59+ driver = neo4j . driver ( 'bolt://localhost' , sharedNeo4j . authToken , {
60+ disableLosslessIntegers : true
61+ } )
62+ session = driver . session ( )
63+
64+ session . run ( 'MATCH (n) DETACH DELETE n' ) . then ( done )
65+ } )
66+
67+ afterEach ( ( ) => {
68+ driver . close ( )
69+ } )
70+
71+ it ( 'should get result summary' , done => {
72+ verifySummary ( session , done )
73+ } )
74+
75+ it ( 'should get plan from summary' , done => {
76+ verifyPlan ( session , done )
77+ } )
78+
79+ it ( 'should get profile from summary' , done => {
80+ verifyProfile ( session , done )
81+ } )
82+
83+ it ( 'should get notifications from summary' , done => {
84+ verifyNotifications ( session , 'EXPLAIN MATCH (n), (m) RETURN n, m' , done )
85+ } )
3686 } )
3787
38- it ( 'should get result summary' , done => {
39- // When & Then
88+ function verifySummary ( session , done ) {
4089 session . run ( "CREATE (p:Person { Name: 'Test'})" ) . then ( result => {
41- let summary = result . summary
90+ const summary = result . summary
4291
4392 expect ( summary . statement . text ) . toBe ( "CREATE (p:Person { Name: 'Test'})" )
4493 expect ( summary . statement . parameters ) . toEqual ( { } )
@@ -50,7 +99,7 @@ describe('#integration result summary', () => {
5099 expect ( summary . resultConsumedAfter ) . toBeDefined ( )
51100 expect ( summary . resultAvailableAfter ) . toBeDefined ( )
52101
53- let counters = summary . counters
102+ const counters = summary . counters
54103 expect ( counters . nodesCreated ( ) ) . toBe ( 1 )
55104 expect ( counters . nodesDeleted ( ) ) . toBe ( 0 )
56105 expect ( counters . relationshipsCreated ( ) ) . toBe ( 0 )
@@ -64,31 +113,31 @@ describe('#integration result summary', () => {
64113 expect ( counters . constraintsRemoved ( ) ) . toBe ( 0 )
65114 done ( )
66115 } )
67- } )
116+ }
68117
69- it ( 'should get plan from summary' , done => {
118+ function verifyPlan ( session , done ) {
70119 session . run ( 'EXPLAIN MATCH (n) RETURN 1' ) . then ( result => {
71- let summary = result . summary
120+ const summary = result . summary
72121 expect ( summary . plan ) . toBeDefined ( )
73122 expect ( summary . profile ) . toBe ( false )
74123
75- let plan = summary . plan
124+ const plan = summary . plan
76125 expect ( plan . arguments ) . toBeDefined ( )
77126 expect ( plan . children ) . toBeDefined ( )
78127 expect ( plan . identifiers ) . toBeDefined ( )
79128 expect ( plan . operatorType ) . toBeDefined ( )
80129 done ( )
81130 } )
82- } )
131+ }
83132
84- it ( 'should get profile from summary' , done => {
133+ function verifyProfile ( session , done ) {
85134 session . run ( 'PROFILE RETURN 1' ) . then ( result => {
86- let summary = result . summary
135+ const summary = result . summary
87136 expect ( summary . plan ) . toBeDefined ( )
88137 expect ( summary . profile ) . toBeDefined ( )
89138
90- let profile = summary . profile
91- let plan = summary . plan
139+ const profile = summary . profile
140+ const plan = summary . plan
92141
93142 verifyProfileAndPlanAreEqual ( profile , plan )
94143
@@ -97,18 +146,14 @@ describe('#integration result summary', () => {
97146
98147 done ( )
99148 } )
100- } )
101-
102- it ( 'should get notifications from summary' , done => {
103- if ( serverVersion . compareTo ( VERSION_4_0_0 ) >= 0 ) {
104- pending ( 'seems to be flaky' )
105- }
149+ }
106150
107- session . run ( 'EXPLAIN MATCH (n), (m) RETURN n, m' ) . then ( result => {
108- let summary = result . summary
151+ function verifyNotifications ( session , statement , done ) {
152+ session . run ( statement ) . then ( result => {
153+ const summary = result . summary
109154 expect ( summary . notifications ) . toBeDefined ( )
110155 expect ( summary . notifications . length ) . toBe ( 1 )
111- let notification = summary . notifications [ 0 ]
156+ const notification = summary . notifications [ 0 ]
112157
113158 expect ( notification . code ) . toBeDefined ( )
114159 expect ( notification . title ) . toBeDefined ( )
@@ -118,7 +163,7 @@ describe('#integration result summary', () => {
118163
119164 done ( )
120165 } )
121- } )
166+ }
122167
123168 function verifyProfileAndPlanAreEqual ( profile , plan ) {
124169 expect ( profile . arguments ) . toBe ( plan . arguments )
0 commit comments