@@ -25,6 +25,16 @@ interface IActionModel {
25
25
* ex: action with size 50 requires 58px of space
26
26
*/
27
27
suite ( '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
+
28
38
test ( 'should return empty primary and secondary actions when given empty initial actions' , ( ) => {
29
39
const result = workbenchCalculateActions ( [ ] , [ ] , 100 ) ;
30
40
assert . deepEqual ( result . primaryActions , [ ] ) ;
@@ -37,20 +47,20 @@ suite('workbenchCalculateActions', () => {
37
47
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
38
48
{ action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
39
49
] ;
40
- const result = workbenchCalculateActions ( actions , [ ] , 200 ) ;
50
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 200 ) ;
41
51
assert . deepEqual ( result . primaryActions , actions . map ( action => action . action ) ) ;
42
- assert . deepEqual ( result . secondaryActions , [ ] ) ;
52
+ assert . deepEqual ( result . secondaryActions , defaultSecondaryActions ) ;
43
53
} ) ;
44
54
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' , ( ) => {
46
56
const actions : IActionModel [ ] = [
47
57
{ action : new Action ( 'action0' , 'Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
48
58
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
49
59
{ action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
50
60
] ;
51
- const result = workbenchCalculateActions ( actions , [ ] , 100 ) ;
61
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 100 ) ;
52
62
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 ) ) ;
54
64
} ) ;
55
65
56
66
test ( 'should ignore second separator when two separators are in a row' , ( ) => {
@@ -60,9 +70,9 @@ suite('workbenchCalculateActions', () => {
60
70
{ action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
61
71
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
62
72
] ;
63
- const result = workbenchCalculateActions ( actions , [ ] , 125 ) ;
73
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 125 ) ;
64
74
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 ) ;
66
76
} ) ;
67
77
68
78
test ( 'should ignore separators when they are at the end of the resulting primary actions' , ( ) => {
@@ -72,21 +82,21 @@ suite('workbenchCalculateActions', () => {
72
82
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
73
83
{ action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
74
84
] ;
75
- const result = workbenchCalculateActions ( actions , [ ] , 200 ) ;
85
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 200 ) ;
76
86
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 ) ;
78
88
} ) ;
79
89
80
- test . skip ( 'should keep actions with size 0 in primary actions' , ( ) => {
90
+ test ( 'should keep actions with size 0 in primary actions' , ( ) => {
81
91
const actions : IActionModel [ ] = [
82
92
{ action : new Action ( 'action0' , 'Action 0' ) , size : 50 , visible : true , renderLabel : true } ,
83
93
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
84
94
{ action : new Action ( 'action2' , 'Action 2' ) , size : 50 , visible : true , renderLabel : true } ,
85
95
{ action : new Action ( 'action3' , 'Action 3' ) , size : 0 , visible : true , renderLabel : true } ,
86
96
] ;
87
- const result = workbenchCalculateActions ( actions , [ ] , 116 ) ;
97
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 116 ) ;
88
98
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 ) ) ;
90
100
} ) ;
91
101
92
102
test ( 'should not render separator if preceeded by size 0 action(s).' , ( ) => {
@@ -95,8 +105,22 @@ suite('workbenchCalculateActions', () => {
95
105
{ action : new Separator ( ) , size : 1 , visible : true , renderLabel : true } ,
96
106
{ action : new Action ( 'action1' , 'Action 1' ) , size : 50 , visible : true , renderLabel : true } ,
97
107
] ;
98
- const result = workbenchCalculateActions ( actions , [ ] , 116 ) ;
108
+ const result = workbenchCalculateActions ( actions , defaultSecondaryActions , 116 ) ;
99
109
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 ) ;
101
125
} ) ;
102
126
} ) ;
0 commit comments