@@ -20,6 +20,7 @@ import {
20
20
import { IPagingState , PagingError } from './paging-state.interface' ;
21
21
import { SampleTestData } from '../test-utils/sample-test-data.spec' ;
22
22
import { Transaction , TransactionType , HierarchicalTransaction } from '../services/public_api' ;
23
+ import { DefaultDataCloneStrategy } from './data-clone-strategy' ;
23
24
24
25
/* Test sorting */
25
26
const testSort = ( ) => {
@@ -516,19 +517,21 @@ const testMerging = () => {
516
517
} ) ;
517
518
518
519
it ( 'Should merge delete transactions correctly' , ( ) => {
520
+ const cloneStrategy = new DefaultDataCloneStrategy ( ) ;
519
521
const data = SampleTestData . personIDNameData ( ) ;
520
522
const secondRow = data [ 1 ] ;
521
523
const transactions : Transaction [ ] = [
522
524
{ id : 1 , newValue : null , type : TransactionType . DELETE } ,
523
525
{ id : 3 , newValue : null , type : TransactionType . DELETE } ,
524
526
] ;
525
527
526
- DataUtil . mergeTransactions ( data , transactions , 'ID' , true ) ;
528
+ DataUtil . mergeTransactions ( data , transactions , 'ID' , cloneStrategy , true ) ;
527
529
expect ( data . length ) . toBe ( 1 ) ;
528
530
expect ( data [ 0 ] ) . toEqual ( secondRow ) ;
529
531
} ) ;
530
532
531
533
it ( 'Should merge add hierarchical transactions correctly' , ( ) => {
534
+ const cloneStrategy = new DefaultDataCloneStrategy ( ) ;
532
535
const data = SampleTestData . employeeSmallTreeData ( ) ;
533
536
const addRootRow = { ID : 1000 , Name : 'Pit Peter' , HireDate : new Date ( 2008 , 3 , 20 ) , Age : 55 } ;
534
537
const addChildRow1 = { ID : 1001 , Name : 'Marry May' , HireDate : new Date ( 2018 , 4 , 1 ) , Age : 102 } ;
@@ -539,7 +542,7 @@ const testMerging = () => {
539
542
{ id : addChildRow2 . ID , newValue : addChildRow2 , type : TransactionType . ADD , path : [ addRootRow . ID ] } ,
540
543
] ;
541
544
542
- DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , false ) ;
545
+ DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , cloneStrategy , false ) ;
543
546
expect ( data . length ) . toBe ( 4 ) ;
544
547
545
548
expect ( data [ 3 ] . Age ) . toBe ( addRootRow . Age ) ;
@@ -555,6 +558,7 @@ const testMerging = () => {
555
558
} ) ;
556
559
557
560
it ( 'Should merge update hierarchical transactions correctly' , ( ) => {
561
+ const cloneStrategy = new DefaultDataCloneStrategy ( ) ;
558
562
const data = SampleTestData . employeeSmallTreeData ( ) ;
559
563
const updateRootRow = { Name : 'May Peter' , Age : 13 } ;
560
564
const updateChildRow1 = { HireDate : new Date ( 2100 , 1 , 12 ) , Age : 1300 } ;
@@ -581,7 +585,7 @@ const testMerging = () => {
581
585
} ,
582
586
] ;
583
587
584
- DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , false ) ;
588
+ DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , cloneStrategy , false ) ;
585
589
expect ( data [ 1 ] . Name ) . toBe ( updateRootRow . Name ) ;
586
590
expect ( data [ 1 ] . Age ) . toBe ( updateRootRow . Age ) ;
587
591
@@ -593,6 +597,7 @@ const testMerging = () => {
593
597
} ) ;
594
598
595
599
it ( 'Should merge delete hierarchical transactions correctly' , ( ) => {
600
+ const cloneStrategy = new DefaultDataCloneStrategy ( ) ;
596
601
const data = SampleTestData . employeeSmallTreeData ( ) ;
597
602
const transactions : HierarchicalTransaction [ ] = [
598
603
// root row with no children
@@ -605,7 +610,7 @@ const testMerging = () => {
605
610
{ id : data [ 0 ] . Employees [ 2 ] . ID , newValue : null , type : TransactionType . DELETE , path : [ data [ 0 ] . ID ] }
606
611
] ;
607
612
608
- DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , true ) ;
613
+ DataUtil . mergeHierarchicalTransactions ( data , transactions , 'Employees' , 'ID' , cloneStrategy , true ) ;
609
614
610
615
expect ( data . length ) . toBe ( 1 ) ;
611
616
expect ( data [ 0 ] . Employees . length ) . toBe ( 1 ) ;
0 commit comments