@@ -11,40 +11,69 @@ describe('weave', function () {
1111 expect ( weave ( ) ) . to . eql ( [ [ ] ] ) ;
1212 } ) ;
1313
14- it ( 'should weave given one array ' , function ( ) {
14+ it ( 'should append to prefix arrays2 if arrays1 is empty ' , function ( ) {
1515 expect ( weave ( [ 2 , 1 ] , [ [ ] ] , [ [ 3 ] ] ) ) . to . eql ( [
1616 [ 2 , 1 , 3 ]
1717 ] ) ;
18+ } ) ;
1819
19- expect ( weave ( [ 2 , 3 ] , [ [ 1 ] ] ) ) . to . eql ( [
20- [ 2 , 3 , 1 ]
20+ it ( 'should append to prefix arrays1 if arrays2 is empty' , function ( ) {
21+ expect ( weave ( [ 2 , 3 ] , [ [ 1 , 4 ] ] ) ) . to . eql ( [
22+ [ 2 , 3 , 1 , 4 ]
2123 ] ) ;
2224 } ) ;
2325
2426 it ( 'should weave given two arrays' , function ( ) {
2527 const prefix = 2 ;
26- const array1 = [ [ 1 ] ] ;
27- const array2 = [ [ 3 ] ] ;
28+ const arrays1 = [ [ 1 ] ] ;
29+ const arrays2 = [ [ 3 ] ] ;
2830 const weaved = [
2931 [ 2 , 1 , 3 ] ,
3032 [ 2 , 3 , 1 ]
3133 ] ;
32- expect ( weave ( prefix , array1 , array2 ) ) . to . eql ( weaved ) ;
34+ expect ( weave ( prefix , arrays1 , arrays2 ) ) . to . eql ( weaved ) ;
3335 } ) ;
3436
35- it . only ( 'should cross array 1 with array 2 keeping the same order' , function ( ) {
37+ /**
38+ * weave(5, [3,2], [8]) = weave([5,3,2], [], [8]) + weave([5, 8], [3,2], [])
39+ */
40+ it ( 'should cross array 1 with array 2 keeping the same order' , function ( ) {
3641 const prefix = 5 ;
37- const array1 = [ [ 3 , 2 ] ] ;
38- const array2 = [ [ 8 , 6 ] ] ;
42+ const arrays1 = [ [ 3 , 2 ] ] ;
43+ const arrays2 = [ [ 8 ] ] ;
44+ const weaved = [
45+ [ 5 , 3 , 2 , 8 ] ,
46+ [ 5 , 3 , 8 , 2 ] ,
47+ [ 5 , 8 , 3 , 2 ] ,
48+ ] ;
49+ expect ( weave ( prefix , arrays1 , arrays2 ) ) . to . eql ( weaved ) ;
50+ } ) ;
51+
52+ it ( 'should cross array 2 with array 1 keeping the same order' , function ( ) {
53+ const prefix = 5 ;
54+ const arrays1 = [ [ 3 ] ] ;
55+ const arrays2 = [ [ 8 , 9 ] ] ;
56+ const weaved = [
57+ [ 5 , 3 , 8 , 9 ] ,
58+ [ 5 , 8 , 3 , 9 ] ,
59+ [ 5 , 8 , 9 , 3 ] ,
60+ ] ;
61+ expect ( weave ( prefix , arrays1 , arrays2 ) ) . to . eql ( weaved ) ;
62+ } ) ;
63+
64+ it ( 'should cross array 1 with array 2 keeping the same order' , function ( ) {
65+ const prefix = 5 ;
66+ const arrays1 = [ [ 3 , 2 ] ] ;
67+ const arrays2 = [ [ 8 , 6 ] ] ;
3968 const weaved = [
4069 [ 5 , 3 , 2 , 8 , 6 ] ,
4170 [ 5 , 3 , 8 , 2 , 6 ] ,
4271 [ 5 , 8 , 3 , 2 , 6 ] ,
4372 [ 5 , 8 , 3 , 6 , 2 ] ,
4473 [ 5 , 8 , 6 , 3 , 2 ] ,
4574 ] ;
46- expect ( weave ( prefix , array1 , array2 ) ) . to . eql ( weaved ) ;
47- } )
75+ expect ( weave ( prefix , arrays1 , arrays2 ) ) . to . eql ( weaved ) ;
76+ } ) ;
4877} ) ;
4978
5079xdescribe ( 'Graph: BST sequence' , function ( ) {
0 commit comments