@@ -55,6 +55,25 @@ describe('util', () => {
55
55
verifyInvalidString ( console . log ) ;
56
56
} ) ;
57
57
58
+ it ( 'should check cypher statements (non-empty strings)' , ( ) => {
59
+ verifyValidString ( new String ( 'foo' ) ) ;
60
+ verifyValidString ( String ( 'foo' ) ) ;
61
+ verifyValidString ( "foo" ) ;
62
+
63
+ verifyInvalidCypherStatement ( '' ) ;
64
+ verifyInvalidCypherStatement ( '\n' ) ;
65
+ verifyInvalidCypherStatement ( '\t' ) ;
66
+ verifyInvalidCypherStatement ( '\r' ) ;
67
+ verifyInvalidCypherStatement ( ' ' ) ;
68
+ verifyInvalidCypherStatement ( ' \n\r' ) ;
69
+ verifyInvalidCypherStatement ( { } ) ;
70
+ verifyInvalidCypherStatement ( { foo : 1 } ) ;
71
+ verifyInvalidCypherStatement ( [ ] ) ;
72
+ verifyInvalidCypherStatement ( [ '1' ] ) ;
73
+ verifyInvalidCypherStatement ( [ 1 , '2' ] ) ;
74
+ verifyInvalidCypherStatement ( console . log ) ;
75
+ } ) ;
76
+
58
77
it ( 'should parse scheme' , ( ) => {
59
78
verifyScheme ( 'bolt://' , 'bolt://localhost' ) ;
60
79
verifyScheme ( 'bolt://' , 'bolt://localhost:7687' ) ;
@@ -169,6 +188,14 @@ describe('util', () => {
169
188
expect ( ( ) => util . assertString ( str , 'Test string' ) ) . toThrowError ( TypeError ) ;
170
189
}
171
190
191
+ function verifyValidCypherStatement ( str ) {
192
+ expect ( util . assertCypherStatement ( str ) ) . toBe ( str ) ;
193
+ }
194
+
195
+ function verifyInvalidCypherStatement ( str ) {
196
+ expect ( ( ) => util . assertCypherStatement ( str ) ) . toThrowError ( TypeError ) ;
197
+ }
198
+
172
199
function verifyScheme ( expectedScheme , url ) {
173
200
expect ( util . parseScheme ( url ) ) . toEqual ( expectedScheme ) ;
174
201
}
0 commit comments