@@ -25,6 +25,16 @@ interface IActionModel {
2525 * ex: action with size 50 requires 58px of space
2626 */
2727suite ( 'workbenchCalculateActions' , ( ) => {
28+
29+ const defaultSecondaryActionModels : IActionModel [ ] = [
30+ { action : new Action ( 'secondaryAction0' , 'Secondary Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
31+ { action : new Action ( 'secondaryAction1' , 'Secondary Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
32+ { action : new Action ( 'secondaryAction2' , 'Secondary Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
33+ ] ;
34+ const defaultSecondaryActions : IAction [ ] = defaultSecondaryActionModels . map ( action => action . action ) ;
35+ const separator : IActionModel = { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ;
36+
37+
2838 test ( 'should return empty primary and secondary actions when given empty initial actions' , ( ) => {
2939 const result = workbenchCalculateActions ( [ ] , [ ] , 100 ) ;
3040 assert . deepEqual ( result . primaryActions , [ ] ) ;
@@ -37,20 +47,20 @@ suite('workbenchCalculateActions', () => {
3747 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
3848 { action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
3949 ] ;
40- const result = workbenchCalculateActions ( actions , [ ] , 200 ) ;
50+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 200 ) ;
4151 assert . deepEqual ( result . primaryActions , actions . map ( action => action . action ) ) ;
42- assert . deepEqual ( result . secondaryActions , [ ] ) ;
52+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
4353 } ) ;
4454
45- test . skip ( 'should move actions to secondary when they do not fit within the container width' , ( ) => {
55+ test ( 'should move actions to secondary when they do not fit within the container width' , ( ) => {
4656 const actions : IActionModel [ ] = [
4757 { action : new Action ( 'action0' , 'Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
4858 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
4959 { action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
5060 ] ;
51- const result = workbenchCalculateActions ( actions , [ ] , 100 ) ;
61+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 100 ) ;
5262 assert . deepEqual ( result . primaryActions , [ actions [ 0 ] ] . map ( action => action . action ) ) ;
53- assert . deepEqual ( result . secondaryActions , [ actions [ 1 ] , actions [ 2 ] ] . map ( action => action . action ) ) ;
63+ assert . deepEqual ( result . secondaryActions , [ actions [ 1 ] , actions [ 2 ] , separator , ... defaultSecondaryActionModels ] . map ( action => action . action ) ) ;
5464 } ) ;
5565
5666 test ( 'should ignore second separator when two separators are in a row' , ( ) => {
@@ -60,9 +70,9 @@ suite('workbenchCalculateActions', () => {
6070 { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
6171 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
6272 ] ;
63- const result = workbenchCalculateActions ( actions , [ ] , 125 ) ;
73+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 125 ) ;
6474 assert . deepEqual ( result . primaryActions , [ actions [ 0 ] , actions [ 1 ] , actions [ 3 ] ] . map ( action => action . action ) ) ;
65- assert . deepEqual ( result . secondaryActions , [ ] ) ;
75+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
6676 } ) ;
6777
6878 test ( 'should ignore separators when they are at the end of the resulting primary actions' , ( ) => {
@@ -72,21 +82,21 @@ suite('workbenchCalculateActions', () => {
7282 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
7383 { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
7484 ] ;
75- const result = workbenchCalculateActions ( actions , [ ] , 200 ) ;
85+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 200 ) ;
7686 assert . deepEqual ( result . primaryActions , [ actions [ 0 ] , actions [ 1 ] , actions [ 2 ] ] . map ( action => action . action ) ) ;
77- assert . deepEqual ( result . secondaryActions , [ ] ) ;
87+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
7888 } ) ;
7989
80- test . skip ( 'should keep actions with size 0 in primary actions' , ( ) => {
90+ test ( 'should keep actions with size 0 in primary actions' , ( ) => {
8191 const actions : IActionModel [ ] = [
8292 { action : new Action ( 'action0' , 'Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
8393 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
8494 { action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
8595 { action : new Action ( 'action3' , 'Action 3' ) , size : 0 , visible : true , renderLabel : true } ,
8696 ] ;
87- const result = workbenchCalculateActions ( actions , [ ] , 116 ) ;
97+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 116 ) ;
8898 assert . deepEqual ( result . primaryActions , [ actions [ 0 ] , actions [ 1 ] , actions [ 3 ] ] . map ( action => action . action ) ) ;
89- assert . deepEqual ( result . secondaryActions , [ actions [ 2 ] ] . map ( action => action . action ) ) ;
99+ assert . deepEqual ( result . secondaryActions , [ actions [ 2 ] , separator , ... defaultSecondaryActionModels ] . map ( action => action . action ) ) ;
90100 } ) ;
91101
92102 test ( 'should not render separator if preceeded by size 0 action(s).' , ( ) => {
@@ -95,8 +105,22 @@ suite('workbenchCalculateActions', () => {
95105 { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
96106 { action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
97107 ] ;
98- const result = workbenchCalculateActions ( actions , [ ] , 116 ) ;
108+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 116 ) ;
99109 assert . deepEqual ( result . primaryActions , [ actions [ 0 ] , actions [ 2 ] ] . map ( action => action . action ) ) ;
100- assert . deepEqual ( result . secondaryActions , [ ] ) ;
110+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
111+ } ) ;
112+
113+ test ( 'should not render second separator if space between is hidden (size 0) actions.' , ( ) => {
114+ const actions : IActionModel [ ] = [
115+ { action : new Action ( 'action0' , 'Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
116+ { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
117+ { action : new Action ( 'action1' , 'Action 1' ) , size : 0 , visible : true , renderLabel : true } ,
118+ { action : new Action ( 'action2' , 'Action 2' ) , size : 0 , visible : true , renderLabel : true } ,
119+ { action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
120+ { action : new Action ( 'action3' , 'Action 3' ) , size : 50 , visible : true , renderLabel : true } ,
121+ ] ;
122+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 300 ) ;
123+ assert . deepEqual ( result . primaryActions , [ actions [ 0 ] , actions [ 1 ] , actions [ 2 ] , actions [ 3 ] , actions [ 5 ] ] . map ( action => action . action ) ) ;
124+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
101125 } ) ;
102126} ) ;
0 commit comments