@@ -9,14 +9,15 @@ import { DockviewGroupPanelModel } from '../../../../dockview/dockviewGroupPanel
9
9
import { fireEvent } from '@testing-library/dom' ;
10
10
import { TestPanel } from '../../dockviewGroupPanelModel.spec' ;
11
11
import { IDockviewPanel } from '../../../../dockview/dockviewPanel' ;
12
+ import { fromPartial } from '@total-typescript/shoehorn' ;
12
13
13
14
describe ( 'tabsContainer' , ( ) => {
14
15
test ( 'that an external event does not render a drop target and calls through to the group mode' , ( ) => {
15
16
const accessorMock = jest . fn < Partial < DockviewComponent > , [ ] > ( ( ) => {
16
17
return {
17
18
onDidAddPanel : jest . fn ( ) ,
18
19
onDidRemovePanel : jest . fn ( ) ,
19
- options : { } ,
20
+ options : { parentElement : document . createElement ( 'div' ) } ,
20
21
} ;
21
22
} ) ;
22
23
const groupviewMock = jest . fn < Partial < DockviewGroupPanelModel > , [ ] > (
@@ -71,7 +72,7 @@ describe('tabsContainer', () => {
71
72
id : 'testcomponentid' ,
72
73
onDidAddPanel : jest . fn ( ) ,
73
74
onDidRemovePanel : jest . fn ( ) ,
74
- options : { } ,
75
+ options : { parentElement : document . createElement ( 'div' ) } ,
75
76
} ;
76
77
} ) ;
77
78
const groupviewMock = jest . fn < Partial < DockviewGroupPanelModel > , [ ] > (
@@ -139,7 +140,7 @@ describe('tabsContainer', () => {
139
140
id : 'testcomponentid' ,
140
141
onDidAddPanel : jest . fn ( ) ,
141
142
onDidRemovePanel : jest . fn ( ) ,
142
- options : { } ,
143
+ options : { parentElement : document . createElement ( 'div' ) } ,
143
144
} ;
144
145
} ) ;
145
146
const groupviewMock = jest . fn < Partial < DockviewGroupPanelModel > , [ ] > (
@@ -204,7 +205,7 @@ describe('tabsContainer', () => {
204
205
id : 'testcomponentid' ,
205
206
onDidAddPanel : jest . fn ( ) ,
206
207
onDidRemovePanel : jest . fn ( ) ,
207
- options : { } ,
208
+ options : { parentElement : document . createElement ( 'div' ) } ,
208
209
} ;
209
210
} ) ;
210
211
const groupviewMock = jest . fn < Partial < DockviewGroupPanelModel > , [ ] > (
@@ -269,7 +270,7 @@ describe('tabsContainer', () => {
269
270
id : 'testcomponentid' ,
270
271
onDidAddPanel : jest . fn ( ) ,
271
272
onDidRemovePanel : jest . fn ( ) ,
272
- options : { } ,
273
+ options : { parentElement : document . createElement ( 'div' ) } ,
273
274
} ;
274
275
} ) ;
275
276
const groupviewMock = jest . fn < Partial < DockviewGroupPanelModel > , [ ] > (
@@ -336,7 +337,7 @@ describe('tabsContainer', () => {
336
337
test ( 'left actions' , ( ) => {
337
338
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
338
339
return ( < Partial < DockviewComponent > > {
339
- options : { } ,
340
+ options : { parentElement : document . createElement ( 'div' ) } ,
340
341
onDidAddPanel : jest . fn ( ) ,
341
342
onDidRemovePanel : jest . fn ( ) ,
342
343
} ) as DockviewComponent ;
@@ -402,7 +403,7 @@ describe('tabsContainer', () => {
402
403
test ( 'right actions' , ( ) => {
403
404
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
404
405
return ( < Partial < DockviewComponent > > {
405
- options : { } ,
406
+ options : { parentElement : document . createElement ( 'div' ) } ,
406
407
onDidAddPanel : jest . fn ( ) ,
407
408
onDidRemovePanel : jest . fn ( ) ,
408
409
} ) as DockviewComponent ;
@@ -468,7 +469,7 @@ describe('tabsContainer', () => {
468
469
test ( 'that a tab will become floating when clicked if not floating and shift is selected' , ( ) => {
469
470
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
470
471
return ( < Partial < DockviewComponent > > {
471
- options : { } ,
472
+ options : { parentElement : document . createElement ( 'div' ) } ,
472
473
onDidAddPanel : jest . fn ( ) ,
473
474
onDidRemovePanel : jest . fn ( ) ,
474
475
element : document . createElement ( 'div' ) ,
@@ -478,7 +479,7 @@ describe('tabsContainer', () => {
478
479
479
480
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
480
481
return ( < Partial < DockviewGroupPanel > > {
481
- api : { location : 'grid' } as any ,
482
+ api : { location : { type : 'grid' } } as any ,
482
483
} ) as DockviewGroupPanel ;
483
484
} ) ;
484
485
@@ -514,21 +515,21 @@ describe('tabsContainer', () => {
514
515
} ,
515
516
{ inDragMode : true }
516
517
) ;
517
- expect ( accessor . addFloatingGroup ) . toBeCalledTimes ( 1 ) ;
518
- expect ( eventPreventDefaultSpy ) . toBeCalledTimes ( 1 ) ;
518
+ expect ( accessor . addFloatingGroup ) . toHaveBeenCalledTimes ( 1 ) ;
519
+ expect ( eventPreventDefaultSpy ) . toHaveBeenCalledTimes ( 1 ) ;
519
520
520
521
const event2 = new KeyboardEvent ( 'mousedown' , { shiftKey : false } ) ;
521
522
const eventPreventDefaultSpy2 = jest . spyOn ( event2 , 'preventDefault' ) ;
522
523
fireEvent ( container , event2 ) ;
523
524
524
- expect ( accessor . addFloatingGroup ) . toBeCalledTimes ( 1 ) ;
525
- expect ( eventPreventDefaultSpy2 ) . toBeCalledTimes ( 0 ) ;
525
+ expect ( accessor . addFloatingGroup ) . toHaveBeenCalledTimes ( 1 ) ;
526
+ expect ( eventPreventDefaultSpy2 ) . toHaveBeenCalledTimes ( 0 ) ;
526
527
} ) ;
527
528
528
529
test ( 'that a tab that is already floating cannot be floated again' , ( ) => {
529
530
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
530
531
return ( < Partial < DockviewComponent > > {
531
- options : { } ,
532
+ options : { parentElement : document . createElement ( 'div' ) } ,
532
533
onDidAddPanel : jest . fn ( ) ,
533
534
onDidRemovePanel : jest . fn ( ) ,
534
535
element : document . createElement ( 'div' ) ,
@@ -538,7 +539,7 @@ describe('tabsContainer', () => {
538
539
539
540
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
540
541
return ( < Partial < DockviewGroupPanel > > {
541
- api : { location : 'floating' } as any ,
542
+ api : { location : { type : 'floating' } } as any ,
542
543
} ) as DockviewGroupPanel ;
543
544
} ) ;
544
545
@@ -580,7 +581,7 @@ describe('tabsContainer', () => {
580
581
test ( 'that selecting a tab with shift down will move that tab into a new floating group' , ( ) => {
581
582
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
582
583
return ( < Partial < DockviewComponent > > {
583
- options : { } ,
584
+ options : { parentElement : document . createElement ( 'div' ) } ,
584
585
onDidAddPanel : jest . fn ( ) ,
585
586
onDidRemovePanel : jest . fn ( ) ,
586
587
element : document . createElement ( 'div' ) ,
@@ -591,7 +592,7 @@ describe('tabsContainer', () => {
591
592
592
593
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
593
594
return ( < Partial < DockviewGroupPanel > > {
594
- api : { location : 'floating' } as any ,
595
+ api : { location : { type : 'floating' } } as any ,
595
596
model : { } as any ,
596
597
} ) as DockviewGroupPanel ;
597
598
} ) ;
@@ -601,23 +602,20 @@ describe('tabsContainer', () => {
601
602
602
603
const cut = new TabsContainer ( accessor , groupPanel ) ;
603
604
604
- const panelMock = jest . fn < IDockviewPanel , [ string ] > ( ( id : string ) => {
605
- const partial : Partial < IDockviewPanel > = {
605
+ const createPanel = ( id : string ) =>
606
+ fromPartial < IDockviewPanel > ( {
606
607
id,
607
-
608
608
view : {
609
609
tab : {
610
610
element : document . createElement ( 'div' ) ,
611
- } as any ,
611
+ } ,
612
612
content : {
613
613
element : document . createElement ( 'div' ) ,
614
- } as any ,
615
- } as any ,
616
- } ;
617
- return partial as IDockviewPanel ;
618
- } ) ;
614
+ } ,
615
+ } ,
616
+ } ) ;
619
617
620
- const panel = new panelMock ( 'test_id' ) ;
618
+ const panel = createPanel ( 'test_id' ) ;
621
619
cut . openPanel ( panel ) ;
622
620
623
621
const el = cut . element . querySelector ( '.tab' ) ! ;
@@ -628,21 +626,21 @@ describe('tabsContainer', () => {
628
626
fireEvent ( el , event ) ;
629
627
630
628
// a floating group with a single tab shouldn't be eligible
631
- expect ( preventDefaultSpy ) . toBeCalledTimes ( 0 ) ;
632
- expect ( accessor . addFloatingGroup ) . toBeCalledTimes ( 0 ) ;
629
+ expect ( preventDefaultSpy ) . toHaveBeenCalledTimes ( 0 ) ;
630
+ expect ( accessor . addFloatingGroup ) . toHaveBeenCalledTimes ( 0 ) ;
633
631
634
- const panel2 = new panelMock ( 'test_id_2' ) ;
632
+ const panel2 = createPanel ( 'test_id_2' ) ;
635
633
cut . openPanel ( panel2 ) ;
636
634
fireEvent ( el , event ) ;
637
635
638
- expect ( preventDefaultSpy ) . toBeCalledTimes ( 1 ) ;
639
- expect ( accessor . addFloatingGroup ) . toBeCalledTimes ( 1 ) ;
636
+ expect ( preventDefaultSpy ) . toHaveBeenCalledTimes ( 1 ) ;
637
+ expect ( accessor . addFloatingGroup ) . toHaveBeenCalledTimes ( 1 ) ;
640
638
} ) ;
641
639
642
640
test ( 'pre header actions' , ( ) => {
643
641
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
644
642
return ( < Partial < DockviewComponent > > {
645
- options : { } ,
643
+ options : { parentElement : document . createElement ( 'div' ) } ,
646
644
onDidAddPanel : jest . fn ( ) ,
647
645
onDidRemovePanel : jest . fn ( ) ,
648
646
element : document . createElement ( 'div' ) ,
@@ -653,7 +651,7 @@ describe('tabsContainer', () => {
653
651
654
652
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
655
653
return ( < Partial < DockviewGroupPanel > > {
656
- api : { location : 'grid' } as any ,
654
+ api : { location : { type : 'grid' } } as any ,
657
655
model : { } as any ,
658
656
} ) as DockviewGroupPanel ;
659
657
} ) ;
@@ -712,7 +710,7 @@ describe('tabsContainer', () => {
712
710
test ( 'left header actions' , ( ) => {
713
711
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
714
712
return ( < Partial < DockviewComponent > > {
715
- options : { } ,
713
+ options : { parentElement : document . createElement ( 'div' ) } ,
716
714
onDidAddPanel : jest . fn ( ) ,
717
715
onDidRemovePanel : jest . fn ( ) ,
718
716
element : document . createElement ( 'div' ) ,
@@ -723,7 +721,7 @@ describe('tabsContainer', () => {
723
721
724
722
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
725
723
return ( < Partial < DockviewGroupPanel > > {
726
- api : { location : 'grid' } as any ,
724
+ api : { location : { type : 'grid' } } as any ,
727
725
model : { } as any ,
728
726
} ) as DockviewGroupPanel ;
729
727
} ) ;
@@ -782,7 +780,7 @@ describe('tabsContainer', () => {
782
780
test ( 'right header actions' , ( ) => {
783
781
const accessorMock = jest . fn < DockviewComponent , [ ] > ( ( ) => {
784
782
return ( < Partial < DockviewComponent > > {
785
- options : { } ,
783
+ options : { parentElement : document . createElement ( 'div' ) } ,
786
784
onDidAddPanel : jest . fn ( ) ,
787
785
onDidRemovePanel : jest . fn ( ) ,
788
786
element : document . createElement ( 'div' ) ,
@@ -793,7 +791,7 @@ describe('tabsContainer', () => {
793
791
794
792
const groupPanelMock = jest . fn < DockviewGroupPanel , [ ] > ( ( ) => {
795
793
return ( < Partial < DockviewGroupPanel > > {
796
- api : { location : 'grid' } as any ,
794
+ api : { location : { type : 'grid' } } as any ,
797
795
model : { } as any ,
798
796
} ) as DockviewGroupPanel ;
799
797
} ) ;
0 commit comments