@@ -55,6 +55,25 @@ describe('util', () => {
5555 verifyInvalidString ( console . log ) ;
5656 } ) ;
5757
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+
5877 it ( 'should parse scheme' , ( ) => {
5978 verifyScheme ( 'bolt://' , 'bolt://localhost' ) ;
6079 verifyScheme ( 'bolt://' , 'bolt://localhost:7687' ) ;
@@ -169,6 +188,14 @@ describe('util', () => {
169188 expect ( ( ) => util . assertString ( str , 'Test string' ) ) . toThrowError ( TypeError ) ;
170189 }
171190
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+
172199 function verifyScheme ( expectedScheme , url ) {
173200 expect ( util . parseScheme ( url ) ) . toEqual ( expectedScheme ) ;
174201 }
0 commit comments