@@ -4,6 +4,14 @@ const getBuildOrder = require('./build-order');
44
55describe ( 'Graph: build order' , function ( ) {
66
7+ it ( 'should work where a node links to a node that cannot immediately follow it' , function ( ) {
8+ const projects = [ 'a' , 'b' , 'c' , 'f' ] ;
9+ const dependencies = [ [ 'f' , 'c' ] , [ 'f' , 'a' ] , [ 'f' , 'b' ] , [ 'c' , 'a' ] , [ 'b' , 'a' ] ] ;
10+ expect ( getBuildOrder ( projects , dependencies ) . join ( '' ) ) . to . match ( / ^ f (? = .* c ) (? = .* b ) .* a $ / ) ;
11+ // https://regex101.com/r/xI9qT0/6
12+ // http://www.rubular.com/r/yf9y5NEi99
13+ } ) ;
14+
715 it ( 'should find the right order' , function ( ) {
816 const projects = [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ] ;
917 const dependencies = [ [ 'a' , 'd' ] , [ 'f' , 'b' ] , [ 'b' , 'd' ] , [ 'f' , 'a' ] , [ 'd' , 'c' ] ] ;
@@ -16,12 +24,6 @@ describe('Graph: build order', function () {
1624 expect ( getBuildOrder ( projects , dependencies ) . join ( ) ) . to . equal ( 'a,b,c,d' ) ;
1725 } ) ;
1826
19- it ( 'should work where a node links to a node that cannot immediately follow it' , function ( ) {
20- const projects = [ 'a' , 'b' , 'c' , 'f' ] ;
21- const dependencies = [ [ 'f' , 'a' ] , [ 'f' , 'c' ] , [ 'f' , 'b' ] , [ 'c' , 'a' ] , [ 'b' , 'a' ] ] ;
22- expect ( getBuildOrder ( projects , dependencies ) . join ( ) ) . to . equal ( 'f,c,b,a' ) ;
23- } ) ;
24-
2527 it ( 'should work with complex graph' , function ( ) {
2628 const projects = [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' ] ;
2729 const dependencies = [ [ 'f' , 'c' ] , [ 'f' , 'b' ] , [ 'f' , 'a' ] , [ 'c' , 'a' ] , [ 'b' , 'a' ] , [ 'a' , 'e' ] , [ 'b' , 'e' ] , [ 'd' , 'g' ] ] ;
0 commit comments