1
1
2
2
var neo4j = require ( "../build/node/neo4j" ) ;
3
+ var StatementType = require ( "../build/node/result" ) . statementType ;
3
4
4
5
describe ( 'session' , function ( ) {
5
6
it ( 'should expose basic run/subscribe ' , function ( done ) {
@@ -10,7 +11,7 @@ describe('session', function() {
10
11
var records = [ ] ;
11
12
driver . session ( ) . run ( "RETURN 1.0 AS a" ) . subscribe ( {
12
13
onNext : function ( record ) {
13
- records . push ( record ) ;
14
+ records . push ( record ) ;
14
15
} ,
15
16
onCompleted : function ( ) {
16
17
expect ( records . length ) . toBe ( 1 ) ;
@@ -52,7 +53,7 @@ describe('session', function() {
52
53
)
53
54
} ) ;
54
55
55
- it ( 'should expose summarize method ' , function ( done ) {
56
+ it ( 'should expose summarize method for basic metadata ' , function ( done ) {
56
57
// Given
57
58
var driver = neo4j . driver ( "neo4j://localhost" ) ;
58
59
var statement = "CREATE (n:Label {prop:{prop}}) RETURN n" ;
@@ -65,7 +66,49 @@ describe('session', function() {
65
66
expect ( sum . statement . parameters ) . toBe ( params ) ;
66
67
expect ( sum . statistics . containsUpdates ( ) ) . toBe ( true ) ;
67
68
expect ( sum . statistics . nodesCreated ( ) ) . toBe ( 1 ) ;
68
- expect ( sum . statementType ) . toBe ( 'rw' ) ;
69
+ expect ( sum . statementType ) . toBe ( StatementType . READ_WRITE ) ;
70
+ driver . close ( ) ;
71
+ done ( ) ;
72
+ } ) ;
73
+ } ) ;
74
+
75
+ it ( 'should expose plan ' , function ( done ) {
76
+ // Given
77
+ var driver = neo4j . driver ( "neo4j://localhost" ) ;
78
+ var statement = "EXPLAIN CREATE (n:Label {prop:{prop}}) RETURN n" ;
79
+ var params = { prop : "string" }
80
+ // When & Then
81
+ var result = driver . session ( ) . run ( statement , params ) ;
82
+ result . then ( function ( records ) {
83
+ var sum = result . summarize ( ) ;
84
+ expect ( sum . hasPlan ( ) ) . toBe ( true ) ;
85
+ expect ( sum . hasProfile ( ) ) . toBe ( false ) ;
86
+ expect ( sum . plan . operatorType ) . toBe ( 'ProduceResults' ) ;
87
+ expect ( sum . plan . arguments . runtime ) . toBe ( 'INTERPRETED' ) ;
88
+ expect ( sum . plan . identifiers [ 0 ] ) . toBe ( 'n' ) ;
89
+ expect ( sum . plan . children [ 0 ] . operatorType ) . toBe ( 'CreateNode' ) ;
90
+ driver . close ( ) ;
91
+ done ( ) ;
92
+ } ) ;
93
+ } ) ;
94
+
95
+ it ( 'should expose profile ' , function ( done ) {
96
+ // Given
97
+ var driver = neo4j . driver ( "neo4j://localhost" ) ;
98
+ var statement = "PROFILE MATCH (n:Label {prop:{prop}}) RETURN n" ;
99
+ var params = { prop : "string" }
100
+ // When & Then
101
+ var result = driver . session ( ) . run ( statement , params ) ;
102
+ result . then ( function ( records ) {
103
+ var sum = result . summarize ( ) ;
104
+ expect ( sum . hasPlan ( ) ) . toBe ( true ) ; //When there's a profile, there's a plan
105
+ expect ( sum . hasProfile ( ) ) . toBe ( true ) ;
106
+ expect ( sum . profile . operatorType ) . toBe ( 'ProduceResults' ) ;
107
+ expect ( sum . profile . arguments . runtime ) . toBe ( 'INTERPRETED' ) ;
108
+ expect ( sum . profile . identifiers [ 0 ] ) . toBe ( 'n' ) ;
109
+ expect ( sum . profile . children [ 0 ] . operatorType ) . toBe ( 'Filter' ) ;
110
+ expect ( sum . profile . rows ) . toBeGreaterThan ( 0 ) ;
111
+ //expect(sum.profile.dbHits).toBeGreaterThan(0);
69
112
driver . close ( ) ;
70
113
done ( ) ;
71
114
} ) ;
0 commit comments