|
@@ -104,6 +104,136 @@ describe('LayoutTreeCrawler', () => {
|
104
|
104
|
});
|
105
|
105
|
});
|
106
|
106
|
|
|
107
|
+ it('Components: extract button style from passedOptions buttons array and merge it to all buttons', () => {
|
|
108
|
+ const MyComponent = class {
|
|
109
|
+ static get options() {
|
|
110
|
+ return {
|
|
111
|
+ topBar: {
|
|
112
|
+ leftButtons: [{
|
|
113
|
+ id: 'id'
|
|
114
|
+ }, {
|
|
115
|
+ id: 'id2'
|
|
116
|
+ }],
|
|
117
|
+ rightButtons: [{
|
|
118
|
+ id: 'id3'
|
|
119
|
+ }]
|
|
120
|
+ }
|
|
121
|
+ };
|
|
122
|
+ }
|
|
123
|
+ };
|
|
124
|
+
|
|
125
|
+ const passedOptions = {
|
|
126
|
+ topBar: {
|
|
127
|
+ leftButtons: {
|
|
128
|
+ font: 'Helvetica'
|
|
129
|
+ },
|
|
130
|
+ rightButtons: []
|
|
131
|
+ }
|
|
132
|
+ };
|
|
133
|
+
|
|
134
|
+ const node = { type: LayoutType.Component, data: { name: 'theComponentName', options: passedOptions } };
|
|
135
|
+ store.setOriginalComponentClassForName('theComponentName', MyComponent);
|
|
136
|
+
|
|
137
|
+ uut.crawl(node);
|
|
138
|
+
|
|
139
|
+ expect(node.data.options).toEqual({
|
|
140
|
+ topBar: {
|
|
141
|
+ leftButtons: [{
|
|
142
|
+ id: 'id',
|
|
143
|
+ font: 'Helvetica'
|
|
144
|
+ }, {
|
|
145
|
+ id: 'id2',
|
|
146
|
+ font: 'Helvetica'
|
|
147
|
+ }],
|
|
148
|
+ rightButtons: [{
|
|
149
|
+ id: 'id3'
|
|
150
|
+ }]
|
|
151
|
+ }
|
|
152
|
+ });
|
|
153
|
+ });
|
|
154
|
+
|
|
155
|
+ it('Components: empty buttons array should not affect static buttons', () => {
|
|
156
|
+ const MyComponent = class {
|
|
157
|
+ static get options() {
|
|
158
|
+ return {
|
|
159
|
+ topBar: {}
|
|
160
|
+ };
|
|
161
|
+ }
|
|
162
|
+ };
|
|
163
|
+
|
|
164
|
+ const passedOptions = {
|
|
165
|
+ topBar: {}
|
|
166
|
+ };
|
|
167
|
+
|
|
168
|
+ const node = { type: LayoutType.Component, data: { name: 'theComponentName', options: passedOptions } };
|
|
169
|
+ store.setOriginalComponentClassForName('theComponentName', MyComponent);
|
|
170
|
+
|
|
171
|
+ uut.crawl(node);
|
|
172
|
+
|
|
173
|
+ expect(node.data.options).toEqual({
|
|
174
|
+ topBar: {}
|
|
175
|
+ });
|
|
176
|
+ });
|
|
177
|
+
|
|
178
|
+ it('Components: static options with no topBar should not crash', () => {
|
|
179
|
+ const MyComponent = class {
|
|
180
|
+ static get options() {
|
|
181
|
+ return {
|
|
182
|
+
|
|
183
|
+ };
|
|
184
|
+ }
|
|
185
|
+ };
|
|
186
|
+
|
|
187
|
+ const passedOptions = {
|
|
188
|
+ topBar: {}
|
|
189
|
+ };
|
|
190
|
+
|
|
191
|
+ const node = { type: LayoutType.Component, data: { name: 'theComponentName', options: passedOptions } };
|
|
192
|
+ store.setOriginalComponentClassForName('theComponentName', MyComponent);
|
|
193
|
+
|
|
194
|
+ uut.crawl(node);
|
|
195
|
+
|
|
196
|
+ expect(node.data.options).toEqual({
|
|
197
|
+ topBar: {}
|
|
198
|
+ });
|
|
199
|
+ });
|
|
200
|
+
|
|
201
|
+ it('Components: undefined passed buttons should not affect static buttons', () => {
|
|
202
|
+ const MyComponent = class {
|
|
203
|
+ static get options() {
|
|
204
|
+ return {
|
|
205
|
+ topBar: {
|
|
206
|
+ leftButtons: [{
|
|
207
|
+ id: 'id'
|
|
208
|
+ }],
|
|
209
|
+ rightButtons: [{
|
|
210
|
+ id: 'id2'
|
|
211
|
+ }]
|
|
212
|
+ }
|
|
213
|
+ };
|
|
214
|
+ }
|
|
215
|
+ };
|
|
216
|
+
|
|
217
|
+ const passedOptions = {
|
|
218
|
+ topBar: {}
|
|
219
|
+ };
|
|
220
|
+
|
|
221
|
+ const node = { type: LayoutType.Component, data: { name: 'theComponentName', options: passedOptions } };
|
|
222
|
+ store.setOriginalComponentClassForName('theComponentName', MyComponent);
|
|
223
|
+
|
|
224
|
+ uut.crawl(node);
|
|
225
|
+
|
|
226
|
+ expect(node.data.options).toEqual({
|
|
227
|
+ topBar: {
|
|
228
|
+ leftButtons: [{
|
|
229
|
+ id: 'id'
|
|
230
|
+ }],
|
|
231
|
+ rightButtons: [{
|
|
232
|
+ id: 'id2'
|
|
233
|
+ }]
|
|
234
|
+ }
|
|
235
|
+ });
|
|
236
|
+ });
|
107
|
237
|
it('Component: deepClones options', () => {
|
108
|
238
|
const theStyle = {};
|
109
|
239
|
const MyComponent = class {
|