@@ -389,9 +389,10 @@ MATCH (dmk:Station {name: 'Denmark Hill'})<-[:CALLS_AT]-(l1a:CallingPoint)-[:NEX
389389 (l2b)-[:CALLS_AT]->(gtw:Station {name: 'Gatwick Airport'})
390390RETURN dmk` ;
391391 const expected = `
392- MATCH (dmk:Station {name: 'Denmark Hill'})<-[:CALLS_AT]-(l1a:CallingPoint)-
393- [:NEXT]->+(l1b)-[:CALLS_AT]->(x:Station)<-[:CALLS_AT]-(l2a:CallingPoint)-
394- [:NEXT]->*(l2b)-[:CALLS_AT]->(gtw:Station {name: 'Gatwick Airport'})
392+ MATCH (dmk:Station {name: 'Denmark Hill'})<-[:CALLS_AT]-
393+ (l1a:CallingPoint)-[:NEXT]->+(l1b)-[:CALLS_AT]->(x:Station)<-[:CALLS_AT]-
394+ (l2a:CallingPoint)-[:NEXT]->*(l2b)-[:CALLS_AT]->
395+ (gtw:Station {name: 'Gatwick Airport'})
395396RETURN dmk` . trim ( ) ;
396397 verifyFormatting ( query , expected ) ;
397398 } ) ;
@@ -544,6 +545,69 @@ RETURN person.name AS name, COUNT {
544545 const expected = query ;
545546 verifyFormatting ( query , expected ) ;
546547 } ) ;
548+
549+ test ( 'should prefer to not split before a relation 1' , ( ) => {
550+ const query = `
551+ MATCH (a:person {name: 'alice', age: 30})-[r:friend_of]->
552+ (b:person {name: 'bob'})-[s:colleague_of]->(c:person {name: 'carol'})-
553+ [t:partner_of]->(d:person {name: 'david'})-[u:mentor_and_friend_of]->
554+ (e:person {name: 'eve'})
555+ RETURN a` ;
556+ const expected = `
557+ MATCH (a:person {name: 'alice', age: 30})-[r:friend_of]->
558+ (b:person {name: 'bob'})-[s:colleague_of]->
559+ (c:person {name: 'carol'})-[t:partner_of]->
560+ (d:person {name: 'david'})-[u:mentor_and_friend_of]->
561+ (e:person {name: 'eve'})
562+ RETURN a` . trimStart ( ) ;
563+ verifyFormatting ( query , expected ) ;
564+ } ) ;
565+
566+ test ( 'should prefer to not split before a relation 2' , ( ) => {
567+ const query = `
568+ MATCH (a:Person {name: 'Alice'}) -[r:KNOWS]->
569+ (b:Person {name: 'Bob'}) -[s:FRIEND_OF]->
570+ (c:Person {name: 'Charlie'})
571+ RETURN a` ;
572+ const expected = `
573+ MATCH (a:Person {name: 'Alice'})-[r:KNOWS]->
574+ (b:Person {name: 'Bob'})-[s:FRIEND_OF]->(c:Person {name: 'Charlie'})
575+ RETURN a` . trimStart ( ) ;
576+ verifyFormatting ( query , expected ) ;
577+ } ) ;
578+
579+ test ( 'should prefer to not split before a relation 3' , ( ) => {
580+ const query = `
581+ MATCH (NOD01)-[REL01]->
582+ (NOD02)-[REL02]->
583+ (NOD03)-[REL03]->
584+ (NOD04)-[REL04]->
585+ (N)-[REL05]->
586+ (NOD06)-[REL06]->
587+ (NOD07)
588+ RETURN NOD01` ;
589+ // The node (N) would fit on the previous line but we prefer to split before nodes
590+ const expected = `
591+ MATCH (NOD01)-[REL01]->(NOD02)-[REL02]->(NOD03)-[REL03]->(NOD04)-[REL04]->
592+ (N)-[REL05]->(NOD06)-[REL06]->(NOD07)
593+ RETURN NOD01` . trimStart ( ) ;
594+ verifyFormatting ( query , expected ) ;
595+ } ) ;
596+
597+ test ( 'should prefer to not split before a relation 4' , ( ) => {
598+ const query = `
599+ MATCH (Alice123:Person)-[FRND_REL:friendship]->
600+ (Bob:Indiv)-[COWORK_REL:colleagueRelationship]->
601+ (Carla55:EmployeeType)-[PARTNR:partner_of]->
602+ (Dave:Short)
603+ RETURN Alice123` ;
604+ const expected = `
605+ MATCH (Alice123:Person)-[FRND_REL:friendship]->
606+ (Bob:Indiv)-[COWORK_REL:colleagueRelationship]->
607+ (Carla55:EmployeeType)-[PARTNR:partner_of]->(Dave:Short)
608+ RETURN Alice123` . trimStart ( ) ;
609+ verifyFormatting ( query , expected ) ;
610+ } ) ;
547611} ) ;
548612
549613describe ( 'tests for respcecting user line breaks' , ( ) => {
0 commit comments