@@ -39,9 +39,7 @@ describe('transfer', () => {
3939 let pageObject : TransferPageObject < AbstractTestTransferComponent > ;
4040
4141 beforeEach ( ( ) => {
42- TestBed . configureTestingModule ( {
43- providers : [ provideNzIconsTesting ( ) , provideNoopAnimations ( ) ]
44- } ) ;
42+ TestBed . configureTestingModule ( { providers : [ provideNzIconsTesting ( ) , provideNoopAnimations ( ) ] } ) ;
4543 fixture = TestBed . createComponent ( TestTransferComponent ) ;
4644 debugElement = fixture . debugElement ;
4745 instance = debugElement . componentInstance ;
@@ -210,6 +208,22 @@ describe('transfer', () => {
210208 expect ( instance . comp . rightDataSource . filter ( w => w . checked ) . length ) . toBe ( 0 ) ;
211209 } ) ;
212210
211+ it ( 'should be checkboxes are toggle select via shift key' , ( ) => {
212+ expect ( instance . comp . rightDataSource . filter ( w => w . checked ) . length ) . toBe ( 0 ) ;
213+ pageObject . checkItem ( 'right' , 0 ) ;
214+ expect ( instance . comp . rightDataSource . filter ( w => w . checked ) . length ) . toBe ( 1 ) ;
215+ window . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'Shift' } ) ) ;
216+ expect ( instance . comp . isShiftPressed ) . toBeTrue ( ) ;
217+ fixture . detectChanges ( ) ;
218+ const multiSelectEndIndex = 9 ;
219+ pageObject . checkItem ( 'right' , multiSelectEndIndex ) ;
220+ expect ( instance . comp . rightDataSource . filter ( w => w . checked ) . length ) . toBe (
221+ COUNT - LEFTCOUNT - DISABLED - multiSelectEndIndex + 1
222+ ) ;
223+ window . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : 'Shift' } ) ) ;
224+ expect ( instance . comp . isShiftPressed ) . toBeFalse ( ) ;
225+ } ) ;
226+
213227 describe ( '#notFoundContent' , ( ) => {
214228 it ( 'should be the left and right list have data' , ( ) => {
215229 instance . nzDataSource = [ { title : `content0` , direction : 'right' } , { title : `content1` } ] ;
@@ -680,22 +694,12 @@ class TestTransferComponent implements OnInit, AbstractTestTransferComponent {
680694} )
681695class TestTransferCustomRenderComponent implements OnInit , AbstractTestTransferComponent {
682696 @ViewChild ( 'comp' , { static : false } ) comp ! : NzTransferComponent ;
683- nzDataSource : Array < {
684- key : string ;
685- title : string ;
686- description : string ;
687- direction : TransferDirection ;
688- icon : string ;
689- } > = [ ] ;
697+ nzDataSource : Array < { key : string ; title : string ; description : string ; direction : TransferDirection ; icon : string } > =
698+ [ ] ;
690699
691700 ngOnInit ( ) : void {
692- const ret : Array < {
693- key : string ;
694- title : string ;
695- description : string ;
696- direction : TransferDirection ;
697- icon : string ;
698- } > = [ ] ;
701+ const ret : Array < { key : string ; title : string ; description : string ; direction : TransferDirection ; icon : string } > =
702+ [ ] ;
699703 for ( let i = 0 ; i < COUNT ; i ++ ) {
700704 ret . push ( {
701705 key : i . toString ( ) ,
@@ -710,21 +714,14 @@ class TestTransferCustomRenderComponent implements OnInit, AbstractTestTransferC
710714}
711715
712716// https://github.com/NG-ZORRO/ng-zorro-antd/issues/996
713- @Component ( {
714- imports : [ NzTransferModule ] ,
715- template : `<nz-transfer [nzDataSource]="list"></nz-transfer>`
716- } )
717+ @Component ( { imports : [ NzTransferModule ] , template : `<nz-transfer [nzDataSource]="list"></nz-transfer>` } )
717718class Test996Component implements OnInit {
718719 @ViewChild ( NzTransferComponent , { static : true } ) comp ! : NzTransferComponent ;
719720 list : NzSafeAny [ ] = [ ] ;
720721
721722 ngOnInit ( ) : void {
722723 for ( let i = 0 ; i < 2 ; i ++ ) {
723- this . list . push ( {
724- key : i . toString ( ) ,
725- title : `content${ i + 1 } ` ,
726- disabled : i % 3 < 1
727- } ) ;
724+ this . list . push ( { key : i . toString ( ) , title : `content${ i + 1 } ` , disabled : i % 3 < 1 } ) ;
728725 }
729726
730727 [ 0 , 1 ] . forEach ( idx => ( this . list [ idx ] . direction = 'right' ) ) ;
0 commit comments