@ons/design-system 72.10.9 → 72.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/components/announcement-banner/_announcement-banner.scss +24 -0
- package/components/announcement-banner/_macro.njk +33 -0
- package/components/announcement-banner/_macro.spec.js +106 -0
- package/components/announcement-banner/_test_examples.js +22 -0
- package/components/announcement-banner/example-banner-black.njk +12 -0
- package/components/announcement-banner/example-banner-red.njk +13 -0
- package/components/announcement-banner/example-banner-teal.njk +13 -0
- package/components/button/_button.scss +29 -1
- package/components/chart/_chart.scss +3 -0
- package/components/chart/_macro.njk +10 -4
- package/components/chart/_macro.spec.js +1150 -642
- package/components/chart/chart-iframe-resize.js +2 -2
- package/components/chart/example-iframe-chart.njk +1 -1
- package/components/duration/example-duration-error-for-single-field.njk +0 -1
- package/components/duration/example-duration-error.njk +0 -1
- package/components/footer/_macro.spec.js +2 -2
- package/components/header/_macro.njk +5 -16
- package/components/header/example-header-button-and-navigation.njk +133 -0
- package/components/header/example-header-external-with-navigation-and-search.njk +1 -1
- package/components/navigation/_macro.njk +11 -16
- package/components/navigation/_navigation.scss +24 -0
- package/components/table/_macro.njk +107 -112
- package/components/table/_macro.spec.js +35 -44
- package/components/table/_table.scss +0 -12
- package/components/table/example-table-sortable.njk +1 -1
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/textarea/_macro.njk +1 -0
- package/components/textarea/_macro.spec.js +1 -0
- package/components/timeout-panel/timeout-panel.spec.js +1 -1
- package/css/main.css +1 -1
- package/layout/_template.njk +13 -0
- package/package.json +3 -3
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/main.scss +1 -0
- package/scss/vars/_colors.scss +3 -0
- package/scss/vars/_forms.scss +11 -0
- package/components/table/example-table-scrollable.njk +0 -158
|
@@ -70,7 +70,7 @@ describe('Macro: Chart', () => {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe('GIVEN: Params:
|
|
73
|
+
describe('GIVEN: Params: instructions', () => {
|
|
74
74
|
describe('WHEN: instructions is provided', () => {
|
|
75
75
|
const $ = cheerio.load(
|
|
76
76
|
renderComponent('chart', {
|
|
@@ -96,7 +96,7 @@ describe('Macro: Chart', () => {
|
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
describe('GIVEN: Params:
|
|
99
|
+
describe('GIVEN: Params: theme', () => {
|
|
100
100
|
describe('WHEN: theme is provided', () => {
|
|
101
101
|
const $ = cheerio.load(
|
|
102
102
|
renderComponent('chart', {
|
|
@@ -111,7 +111,7 @@ describe('Macro: Chart', () => {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
describe('GIVEN: Params:
|
|
114
|
+
describe('GIVEN: Params: headingLevel', () => {
|
|
115
115
|
describe('WHEN: heading level is provided', () => {
|
|
116
116
|
const $ = cheerio.load(
|
|
117
117
|
renderComponent('chart', {
|
|
@@ -141,7 +141,7 @@ describe('Macro: Chart', () => {
|
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
describe('GIVEN: Params:
|
|
144
|
+
describe('GIVEN: Params: tickInterval', () => {
|
|
145
145
|
describe('WHEN: tick interval is provided', () => {
|
|
146
146
|
const $ = cheerio.load(
|
|
147
147
|
renderComponent('chart', {
|
|
@@ -173,39 +173,146 @@ describe('Macro: Chart', () => {
|
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
describe('GIVEN: Params:
|
|
177
|
-
describe('WHEN:
|
|
176
|
+
describe('GIVEN: Params: xAxis', () => {
|
|
177
|
+
describe('WHEN: xAxis options are provided', () => {
|
|
178
178
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
179
179
|
const configScript = $(`script[data-highcharts-config--chart-456]`).html();
|
|
180
180
|
|
|
181
|
-
test('THEN: it renders the
|
|
182
|
-
expect(configScript).toContain('"enabled":true');
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('THEN: it includes correct xAxis properties', () => {
|
|
181
|
+
test('THEN: it renders the xAxis correctly', () => {
|
|
186
182
|
expect(configScript).toContain('"text":"X Axis Label"');
|
|
187
183
|
expect(configScript).toContain('"categories":["A","B","C"]');
|
|
188
|
-
expect(configScript).toContain('"type":"linear"');
|
|
189
184
|
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('WHEN: xAxis min and max are provided', () => {
|
|
188
|
+
test('THEN: xAxis min and max are ignored', () => {
|
|
189
|
+
const params = {
|
|
190
|
+
id: 'test-chart',
|
|
191
|
+
title: 'Test Chart',
|
|
192
|
+
chartType: 'line',
|
|
193
|
+
xAxis: {
|
|
194
|
+
title: 'X Axis Title',
|
|
195
|
+
categories: ['A', 'B', 'C'],
|
|
196
|
+
type: 'linear',
|
|
197
|
+
labelFormat: '{value}',
|
|
198
|
+
min: 1,
|
|
199
|
+
max: 10,
|
|
200
|
+
startOnTick: true,
|
|
201
|
+
endOnTick: true,
|
|
202
|
+
},
|
|
203
|
+
yAxis: {
|
|
204
|
+
title: 'Y Axis Title',
|
|
205
|
+
labelFormat: '{value}',
|
|
206
|
+
},
|
|
207
|
+
series: [],
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
211
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
212
|
+
|
|
213
|
+
expect(configScript).not.toContain('"min":1');
|
|
214
|
+
expect(configScript).not.toContain('"max":10');
|
|
215
|
+
expect(configScript).not.toContain('"startOnTick":true');
|
|
216
|
+
expect(configScript).not.toContain('"endOnTick":true');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
190
220
|
|
|
191
|
-
|
|
221
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
222
|
+
describe('WHEN: yAxis options are provided', () => {
|
|
223
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
224
|
+
const configScript = $(`script[data-highcharts-config--chart-456]`).html();
|
|
225
|
+
|
|
226
|
+
test('THEN: it renders the yAxis correctly', () => {
|
|
192
227
|
expect(configScript).toContain('"text":"Y Axis Label"');
|
|
193
228
|
expect(configScript).toContain('"labels":{"format":"{value:,.f}"}');
|
|
194
229
|
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe('WHEN: yAxis min and max are provided', () => {
|
|
233
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
234
|
+
const params = {
|
|
235
|
+
id: 'test-chart',
|
|
236
|
+
title: 'Test Chart',
|
|
237
|
+
xAxis: {
|
|
238
|
+
title: 'X Axis Title',
|
|
239
|
+
categories: ['A', 'B', 'C'],
|
|
240
|
+
type: 'linear',
|
|
241
|
+
labelFormat: '{value}',
|
|
242
|
+
},
|
|
243
|
+
chartType: 'line',
|
|
244
|
+
yAxis: {
|
|
245
|
+
title: 'Y Axis Title',
|
|
246
|
+
labelFormat: '{value}',
|
|
247
|
+
min: 0,
|
|
248
|
+
max: 100,
|
|
249
|
+
startOnTick: false,
|
|
250
|
+
endOnTick: true,
|
|
251
|
+
},
|
|
252
|
+
series: [],
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
256
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
257
|
+
|
|
258
|
+
expect(configScript).toContain('"min":0');
|
|
259
|
+
expect(configScript).toContain('"max":100');
|
|
260
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
261
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe('WHEN: yAxis min and max are not provided', () => {
|
|
266
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
267
|
+
const params = {
|
|
268
|
+
id: 'test-chart',
|
|
269
|
+
title: 'Test Chart',
|
|
270
|
+
xAxis: {
|
|
271
|
+
title: 'X Axis Title',
|
|
272
|
+
categories: ['A', 'B', 'C'],
|
|
273
|
+
type: 'linear',
|
|
274
|
+
labelFormat: '{value}',
|
|
275
|
+
},
|
|
276
|
+
chartType: 'line',
|
|
277
|
+
yAxis: {
|
|
278
|
+
title: 'Y Axis Title',
|
|
279
|
+
labelFormat: '{value}',
|
|
280
|
+
min: undefined,
|
|
281
|
+
max: undefined,
|
|
282
|
+
startOnTick: undefined,
|
|
283
|
+
endOnTick: undefined,
|
|
284
|
+
},
|
|
285
|
+
series: [],
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
289
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
290
|
+
|
|
291
|
+
const config = JSON.parse(configScript);
|
|
292
|
+
|
|
293
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
294
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
295
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
296
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('GIVEN: Params: series', () => {
|
|
302
|
+
describe('WHEN: series data is provided', () => {
|
|
303
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
304
|
+
const configScript = $(`script[data-highcharts-config--chart-456]`).html();
|
|
195
305
|
|
|
196
|
-
test('THEN: it
|
|
306
|
+
test('THEN: it renders the series correctly', () => {
|
|
197
307
|
expect(configScript).toContain('"name":"Category 1"');
|
|
198
308
|
expect(configScript).toContain('"data":[5,15,25]');
|
|
199
309
|
expect(configScript).toContain('"name":"Category 2"');
|
|
200
310
|
expect(configScript).toContain('"data":[10,20,30]');
|
|
201
|
-
expect(configScript).toContain('"connectNulls":true');
|
|
202
|
-
expect(configScript).toContain('"marker":{"enabled":true}');
|
|
203
|
-
expect(configScript).toContain('"dataLabels":{"enabled":true}');
|
|
204
311
|
});
|
|
205
312
|
});
|
|
206
313
|
});
|
|
207
314
|
|
|
208
|
-
describe('GIVEN: Params:
|
|
315
|
+
describe('GIVEN: Params: percentageHeightDesktop', () => {
|
|
209
316
|
describe('WHEN: percentage height desktop is provided', () => {
|
|
210
317
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
211
318
|
test('THEN: it includes correct percentage height desktop', () => {
|
|
@@ -214,7 +321,7 @@ describe('Macro: Chart', () => {
|
|
|
214
321
|
});
|
|
215
322
|
});
|
|
216
323
|
|
|
217
|
-
describe('GIVEN: Params:
|
|
324
|
+
describe('GIVEN: Params: percentageHeightMobile', () => {
|
|
218
325
|
describe('WHEN: percentage height mobile is provided', () => {
|
|
219
326
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_CONFIG_PARAMS));
|
|
220
327
|
test('THEN: it includes correct percentage height mobile', () => {
|
|
@@ -252,9 +359,7 @@ describe('Macro: Chart', () => {
|
|
|
252
359
|
expect(noScriptFallbackImage).toContain('alt="A description of the fallback image for screen readers"');
|
|
253
360
|
});
|
|
254
361
|
});
|
|
255
|
-
});
|
|
256
362
|
|
|
257
|
-
describe('GIVEN: Params: no fallbackImageAlt', () => {
|
|
258
363
|
describe('WHEN: fallbackImageAlt is not provided', () => {
|
|
259
364
|
const $ = cheerio.load(
|
|
260
365
|
renderComponent('chart', {
|
|
@@ -269,7 +374,7 @@ describe('Macro: Chart', () => {
|
|
|
269
374
|
});
|
|
270
375
|
});
|
|
271
376
|
|
|
272
|
-
describe('GIVEN: Params:
|
|
377
|
+
describe('GIVEN: Params: caption', () => {
|
|
273
378
|
describe('WHEN: caption is provided', () => {
|
|
274
379
|
const $ = cheerio.load(
|
|
275
380
|
renderComponent('chart', {
|
|
@@ -308,7 +413,7 @@ describe('Macro: Chart', () => {
|
|
|
308
413
|
});
|
|
309
414
|
});
|
|
310
415
|
|
|
311
|
-
describe('GIVEN: Params:
|
|
416
|
+
describe('GIVEN: Params: description', () => {
|
|
312
417
|
describe('WHEN: description is provided', () => {
|
|
313
418
|
const $ = cheerio.load(
|
|
314
419
|
renderComponent('chart', {
|
|
@@ -323,8 +428,8 @@ describe('Macro: Chart', () => {
|
|
|
323
428
|
});
|
|
324
429
|
});
|
|
325
430
|
|
|
326
|
-
describe('GIVEN: Params:
|
|
327
|
-
describe('WHEN: download object
|
|
431
|
+
describe('GIVEN: Params: download', () => {
|
|
432
|
+
describe('WHEN: download object is provided', () => {
|
|
328
433
|
const $ = cheerio.load(
|
|
329
434
|
renderComponent('chart', {
|
|
330
435
|
...EXAMPLE_LINE_CHART_REQUIRED_PARAMS,
|
|
@@ -350,7 +455,7 @@ describe('Macro: Chart', () => {
|
|
|
350
455
|
});
|
|
351
456
|
});
|
|
352
457
|
|
|
353
|
-
describe('GIVEN: Params:
|
|
458
|
+
describe('GIVEN: Params: legend', () => {
|
|
354
459
|
describe('WHEN: legend parameter is provided and set to true', () => {
|
|
355
460
|
const $ = cheerio.load(
|
|
356
461
|
renderComponent('chart', {
|
|
@@ -392,12 +497,145 @@ describe('Macro: Chart', () => {
|
|
|
392
497
|
legend: 'false',
|
|
393
498
|
}),
|
|
394
499
|
);
|
|
395
|
-
test('THEN: it renders the legend', () => {
|
|
500
|
+
test('THEN: it renders the legend default value', () => {
|
|
396
501
|
const configScript = $(`script[data-highcharts-config--line-chart-legend-tests-123]`).html();
|
|
397
502
|
expect(configScript).toContain('"legend":{"enabled":true}');
|
|
398
503
|
});
|
|
399
504
|
});
|
|
400
505
|
});
|
|
506
|
+
|
|
507
|
+
describe('GIVEN: Params: rangeAnnotations', () => {
|
|
508
|
+
describe('WHEN: range annotations params are provided on the yAxis with label width', () => {
|
|
509
|
+
const $ = cheerio.load(
|
|
510
|
+
renderComponent('chart', EXAMPLE_LINE_CHART_WITH_RANGE_ANNOTATION_ON_Y_AXIS_WITH_LABEL_WIDTH_PARAMS),
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
514
|
+
const results = await axe($.html());
|
|
515
|
+
expect(results).toHaveNoViolations();
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test('THEN: it includes the range annotations JSON config', () => {
|
|
519
|
+
const configScript = $(`script[data-highcharts-range-annotations--line-chart-range-annotations-y-axis-123]`).html();
|
|
520
|
+
expect(configScript).toContain('"text":"A test y axis range annotation with a label width of 250px"');
|
|
521
|
+
expect(configScript).toContain('"axis":"y"');
|
|
522
|
+
expect(configScript).toContain('"labelWidth":250');
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
describe('WHEN: range annotations params are provided on the xAxis', () => {
|
|
527
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_RANGE_ANNOTATION_ON_X_AXIS_PARAMS));
|
|
528
|
+
|
|
529
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
530
|
+
const results = await axe($.html());
|
|
531
|
+
expect(results).toHaveNoViolations();
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
test('THEN: it includes the range annotations JSON config', () => {
|
|
535
|
+
const configScript = $(`script[data-highcharts-range-annotations--line-chart-range-annotations-x-axis-123]`).html();
|
|
536
|
+
expect(configScript).toContain('"text":"A test x axis range annotation"');
|
|
537
|
+
expect(configScript).toContain('"range":{"axisValue1":10,"axisValue2":15}');
|
|
538
|
+
expect(configScript).toContain('"axis":"x"');
|
|
539
|
+
expect(configScript).toContain('"labelOffsetX":150');
|
|
540
|
+
expect(configScript).toContain('"labelOffsetY":0');
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
describe('WHEN: range annotations params are provided with label inside', () => {
|
|
545
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_RANGE_ANNOTATION_WITH_LABEL_INSIDE_PARAMS));
|
|
546
|
+
|
|
547
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
548
|
+
const results = await axe($.html());
|
|
549
|
+
expect(results).toHaveNoViolations();
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
test('THEN: it includes the range annotations JSON config', () => {
|
|
553
|
+
const configScript = $(
|
|
554
|
+
`script[data-highcharts-range-annotations--line-chart-range-annotations-label-inside-123]`,
|
|
555
|
+
).html();
|
|
556
|
+
expect(configScript).toContain('"text":"A test y axis range annotation with the label inside"');
|
|
557
|
+
expect(configScript).toContain('"axis":"y"');
|
|
558
|
+
expect(configScript).toContain('"labelInside":true');
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
describe('GIVEN: Params: referenceLineAnnotations', () => {
|
|
564
|
+
describe('WHEN: reference line annotations params are provided', () => {
|
|
565
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_REFERENCE_LINE_ANNOTATIONS_PARAMS));
|
|
566
|
+
|
|
567
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
568
|
+
const results = await axe($.html());
|
|
569
|
+
expect(results).toHaveNoViolations();
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
test('THEN: it includes the reference line annotations JSON config', () => {
|
|
573
|
+
const configScript = $(
|
|
574
|
+
`script[data-highcharts-reference-line-annotations--line-chart-reference-line-annotations-123]`,
|
|
575
|
+
).html();
|
|
576
|
+
expect(configScript).toContain('"text":"A test x axis reference line annotation"');
|
|
577
|
+
expect(configScript).toContain('"value":34');
|
|
578
|
+
expect(configScript).toContain('"axis":"x"');
|
|
579
|
+
expect(configScript).toContain('"text":"A test y axis reference line annotation"');
|
|
580
|
+
expect(configScript).toContain('"value":12');
|
|
581
|
+
expect(configScript).toContain('"axis":"y"');
|
|
582
|
+
expect(configScript).toContain('"labelWidth":100');
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
describe('GIVEN: Params: annotations', () => {
|
|
588
|
+
describe('WHEN: annotations params are provided', () => {
|
|
589
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_ANNOTATIONS_PARAMS));
|
|
590
|
+
|
|
591
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
592
|
+
const results = await axe($.html());
|
|
593
|
+
expect(results).toHaveNoViolations();
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
test('THEN: it renders the footnotes', () => {
|
|
597
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
598
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
599
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('2');
|
|
600
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('Another test annotation');
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
604
|
+
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
test('THEN: it includes the annotations JSON config', () => {
|
|
608
|
+
const configScript = $(`script[data-highcharts-annotations--line-chart-annotations-123]`).html();
|
|
609
|
+
expect(configScript).toContain('"text":"A test annotation"');
|
|
610
|
+
expect(configScript).toContain('"point":{"x":10,"y":1.3}');
|
|
611
|
+
expect(configScript).toContain('"labelOffsetX":10,"labelOffsetY":-50');
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
describe('GIVEN: Params: mixedAnnotations', () => {
|
|
617
|
+
describe('WHEN: mixed annotations params are provided', () => {
|
|
618
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_MIXED_ANNOTATION_TYPES_PARAMS));
|
|
619
|
+
|
|
620
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
621
|
+
const results = await axe($.html());
|
|
622
|
+
expect(results).toHaveNoViolations();
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
test('THEN: it renders the footnotes sequentially', () => {
|
|
626
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
627
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test point annotation');
|
|
628
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('2');
|
|
629
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test x axis range annotation');
|
|
630
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('3');
|
|
631
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis range annotation with the label inside');
|
|
632
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('4');
|
|
633
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test x axis reference line annotation');
|
|
634
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('5');
|
|
635
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis reference line annotation');
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
});
|
|
401
639
|
});
|
|
402
640
|
|
|
403
641
|
describe('FOR: Bar Chart', () => {
|
|
@@ -430,29 +668,159 @@ describe('Macro: Chart', () => {
|
|
|
430
668
|
});
|
|
431
669
|
});
|
|
432
670
|
|
|
433
|
-
describe('GIVEN: Params:
|
|
434
|
-
describe('WHEN:
|
|
435
|
-
const $ = cheerio.load(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
})
|
|
440
|
-
);
|
|
671
|
+
describe('GIVEN: Params: legend', () => {
|
|
672
|
+
describe('WHEN: legend is true', () => {
|
|
673
|
+
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_BAR_CHART_PARAMS, legend: true }));
|
|
674
|
+
|
|
675
|
+
test('THEN: it renders the legend', () => {
|
|
676
|
+
const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
|
|
677
|
+
expect(configScript).toContain('"legend":{"enabled":true}');
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
describe('WHEN: legend is false', () => {
|
|
682
|
+
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_BAR_CHART_PARAMS, legend: false }));
|
|
441
683
|
|
|
442
|
-
test('THEN: it
|
|
684
|
+
test('THEN: it disables the legend', () => {
|
|
443
685
|
const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
|
|
444
|
-
expect(configScript).toContain('"enabled":
|
|
686
|
+
expect(configScript).toContain('"legend":{"enabled":false}');
|
|
445
687
|
});
|
|
688
|
+
});
|
|
446
689
|
|
|
447
|
-
|
|
690
|
+
describe('WHEN: legend is not provided', () => {
|
|
691
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_PARAMS));
|
|
692
|
+
|
|
693
|
+
test('THEN: it defaults to enabled', () => {
|
|
448
694
|
const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
|
|
695
|
+
expect(configScript).toContain('"legend":{"enabled":true}');
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
describe('GIVEN: Params: xAxis', () => {
|
|
701
|
+
describe('WHEN: xAxis options are provided', () => {
|
|
702
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_PARAMS));
|
|
703
|
+
const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
|
|
704
|
+
|
|
705
|
+
test('THEN: it renders the xAxis correctly', () => {
|
|
449
706
|
expect(configScript).toContain('"text":"X Axis Title"');
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
describe('WHEN: xAxis min and max are provided', () => {
|
|
711
|
+
test('THEN: xAxis min and max are ignored', () => {
|
|
712
|
+
const params = {
|
|
713
|
+
id: 'test-chart',
|
|
714
|
+
title: 'Test Chart',
|
|
715
|
+
chartType: 'bar',
|
|
716
|
+
xAxis: {
|
|
717
|
+
title: 'X Axis Title',
|
|
718
|
+
categories: ['A', 'B', 'C'],
|
|
719
|
+
type: 'linear',
|
|
720
|
+
labelFormat: '{value}',
|
|
721
|
+
min: 1,
|
|
722
|
+
max: 10,
|
|
723
|
+
startOnTick: true,
|
|
724
|
+
endOnTick: true,
|
|
725
|
+
},
|
|
726
|
+
yAxis: {
|
|
727
|
+
title: 'Y Axis Title',
|
|
728
|
+
labelFormat: '{value}',
|
|
729
|
+
},
|
|
730
|
+
series: [],
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
734
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
735
|
+
|
|
736
|
+
expect(configScript).not.toContain('"min":1');
|
|
737
|
+
expect(configScript).not.toContain('"max":10');
|
|
738
|
+
expect(configScript).not.toContain('"startOnTick":true');
|
|
739
|
+
expect(configScript).not.toContain('"endOnTick":true');
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
745
|
+
describe('WHEN: yAxis options are provided', () => {
|
|
746
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_PARAMS));
|
|
747
|
+
const configScript = $(`script[data-highcharts-config--bar-chart-123]`).html();
|
|
748
|
+
|
|
749
|
+
test('THEN: it renders the yAxis correctly', () => {
|
|
450
750
|
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
451
751
|
});
|
|
452
752
|
});
|
|
753
|
+
|
|
754
|
+
describe('WHEN: yAxis min and max are provided', () => {
|
|
755
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
756
|
+
const params = {
|
|
757
|
+
id: 'test-chart',
|
|
758
|
+
title: 'Test Chart',
|
|
759
|
+
xAxis: {
|
|
760
|
+
title: 'X Axis Title',
|
|
761
|
+
categories: ['A', 'B', 'C'],
|
|
762
|
+
type: 'linear',
|
|
763
|
+
labelFormat: '{value}',
|
|
764
|
+
},
|
|
765
|
+
chartType: 'line',
|
|
766
|
+
yAxis: {
|
|
767
|
+
title: 'Y Axis Title',
|
|
768
|
+
labelFormat: '{value}',
|
|
769
|
+
min: 0,
|
|
770
|
+
max: 100,
|
|
771
|
+
startOnTick: false,
|
|
772
|
+
endOnTick: true,
|
|
773
|
+
},
|
|
774
|
+
series: [],
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
778
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
779
|
+
|
|
780
|
+
expect(configScript).toContain('"min":0');
|
|
781
|
+
expect(configScript).toContain('"max":100');
|
|
782
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
783
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
describe('WHEN: yAxis min and max are not provided', () => {
|
|
788
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
789
|
+
const params = {
|
|
790
|
+
id: 'test-chart',
|
|
791
|
+
title: 'Test Chart',
|
|
792
|
+
xAxis: {
|
|
793
|
+
title: 'X Axis Title',
|
|
794
|
+
categories: ['A', 'B', 'C'],
|
|
795
|
+
type: 'linear',
|
|
796
|
+
labelFormat: '{value}',
|
|
797
|
+
},
|
|
798
|
+
chartType: 'line',
|
|
799
|
+
yAxis: {
|
|
800
|
+
title: 'Y Axis Title',
|
|
801
|
+
labelFormat: '{value}',
|
|
802
|
+
min: undefined,
|
|
803
|
+
max: undefined,
|
|
804
|
+
startOnTick: undefined,
|
|
805
|
+
endOnTick: undefined,
|
|
806
|
+
},
|
|
807
|
+
series: [],
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
811
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
812
|
+
|
|
813
|
+
const config = JSON.parse(configScript);
|
|
814
|
+
|
|
815
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
816
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
817
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
818
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
819
|
+
});
|
|
820
|
+
});
|
|
453
821
|
});
|
|
454
822
|
|
|
455
|
-
describe('GIVEN: Params:
|
|
823
|
+
describe('GIVEN: Params: percentageHeightDesktop', () => {
|
|
456
824
|
describe('WHEN: percentage height desktop is provided', () => {
|
|
457
825
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_WITH_PERCENTAGE_HEIGHT_PARAMS));
|
|
458
826
|
test('THEN: it does not include percentage height desktop', () => {
|
|
@@ -461,7 +829,7 @@ describe('Macro: Chart', () => {
|
|
|
461
829
|
});
|
|
462
830
|
});
|
|
463
831
|
|
|
464
|
-
describe('GIVEN: Params:
|
|
832
|
+
describe('GIVEN: Params: percentageHeightMobile', () => {
|
|
465
833
|
describe('WHEN: percentage height mobile is provided', () => {
|
|
466
834
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_WITH_PERCENTAGE_HEIGHT_PARAMS));
|
|
467
835
|
test('THEN: it does not include percentage height mobile', () => {
|
|
@@ -470,7 +838,7 @@ describe('Macro: Chart', () => {
|
|
|
470
838
|
});
|
|
471
839
|
});
|
|
472
840
|
|
|
473
|
-
describe('GIVEN: Params:
|
|
841
|
+
describe('GIVEN: Params: caption', () => {
|
|
474
842
|
describe('WHEN: caption is provided', () => {
|
|
475
843
|
const $ = cheerio.load(
|
|
476
844
|
renderComponent('chart', {
|
|
@@ -485,7 +853,7 @@ describe('Macro: Chart', () => {
|
|
|
485
853
|
});
|
|
486
854
|
});
|
|
487
855
|
|
|
488
|
-
describe('GIVEN: Params:
|
|
856
|
+
describe('GIVEN: Params: description', () => {
|
|
489
857
|
describe('WHEN: description is provided', () => {
|
|
490
858
|
const $ = cheerio.load(
|
|
491
859
|
renderComponent('chart', {
|
|
@@ -500,8 +868,8 @@ describe('Macro: Chart', () => {
|
|
|
500
868
|
});
|
|
501
869
|
});
|
|
502
870
|
|
|
503
|
-
describe('GIVEN: Params:
|
|
504
|
-
describe('WHEN: download object
|
|
871
|
+
describe('GIVEN: Params: download', () => {
|
|
872
|
+
describe('WHEN: download object is provided', () => {
|
|
505
873
|
const $ = cheerio.load(
|
|
506
874
|
renderComponent('chart', {
|
|
507
875
|
...EXAMPLE_BAR_CHART_PARAMS,
|
|
@@ -527,8 +895,8 @@ describe('Macro: Chart', () => {
|
|
|
527
895
|
});
|
|
528
896
|
});
|
|
529
897
|
|
|
530
|
-
describe('GIVEN:
|
|
531
|
-
describe('WHEN:
|
|
898
|
+
describe('GIVEN: Params: useStackedLayout', () => {
|
|
899
|
+
describe('WHEN: useStackedLayout is set to true', () => {
|
|
532
900
|
const $ = cheerio.load(
|
|
533
901
|
renderComponent('chart', {
|
|
534
902
|
...EXAMPLE_BAR_CHART_PARAMS,
|
|
@@ -545,61 +913,199 @@ describe('Macro: Chart', () => {
|
|
|
545
913
|
});
|
|
546
914
|
});
|
|
547
915
|
});
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
describe('FOR: Column Chart', () => {
|
|
551
|
-
describe('GIVEN: Params: required', () => {
|
|
552
|
-
describe('WHEN: required params are provided', () => {
|
|
553
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
554
916
|
|
|
917
|
+
describe('GIVEN: Params: annotations', () => {
|
|
918
|
+
describe('WHEN: annotations params are provided', () => {
|
|
919
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_WITH_ANNOTATIONS_PARAMS));
|
|
555
920
|
test('THEN: it passes jest-axe checks', async () => {
|
|
556
921
|
const results = await axe($.html());
|
|
557
922
|
expect(results).toHaveNoViolations();
|
|
558
923
|
});
|
|
559
924
|
|
|
560
|
-
test('THEN: it renders the
|
|
561
|
-
expect($('
|
|
562
|
-
expect($('
|
|
563
|
-
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Column Chart');
|
|
564
|
-
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('column-chart-123');
|
|
925
|
+
test('THEN: it renders the footnotes', () => {
|
|
926
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
927
|
+
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
565
928
|
});
|
|
566
929
|
|
|
567
|
-
test('THEN:
|
|
568
|
-
expect($('
|
|
569
|
-
expect($('.ons-chart__download-title').length).toBe(0);
|
|
930
|
+
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
931
|
+
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
570
932
|
});
|
|
571
933
|
|
|
572
|
-
test('THEN: it includes the
|
|
573
|
-
const configScript = $(`script[data-highcharts-
|
|
574
|
-
expect(configScript).toContain('"text":"
|
|
575
|
-
expect(configScript).toContain('"
|
|
934
|
+
test('THEN: it includes the annotations JSON config', () => {
|
|
935
|
+
const configScript = $(`script[data-highcharts-annotations--bar-chart-annotations-123]`).html();
|
|
936
|
+
expect(configScript).toContain('"text":"A test annotation"');
|
|
937
|
+
expect(configScript).toContain('"point":{"x":2,"y":3}');
|
|
938
|
+
expect(configScript).toContain('"labelOffsetX":10,"labelOffsetY":-50');
|
|
576
939
|
});
|
|
577
940
|
});
|
|
578
941
|
});
|
|
579
942
|
|
|
580
|
-
describe('GIVEN: Params:
|
|
581
|
-
describe('WHEN:
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
);
|
|
943
|
+
describe('GIVEN: Params: Series', () => {
|
|
944
|
+
describe('WHEN: chartType is not compatible with line series', () => {
|
|
945
|
+
const params = {
|
|
946
|
+
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
947
|
+
chartType: 'bar',
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
951
|
+
const configScript = $('script[data-highcharts-config--column-chart-123]').html();
|
|
952
|
+
|
|
953
|
+
test('THEN: it falls back to chartType and does not include "line" series', () => {
|
|
954
|
+
expect(configScript).not.toContain('"type":"line"');
|
|
955
|
+
expect(configScript).toContain('"type":"bar"');
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
describe('FOR: Column Chart', () => {
|
|
962
|
+
describe('GIVEN: Params: required', () => {
|
|
963
|
+
describe('WHEN: required params are provided', () => {
|
|
964
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
965
|
+
|
|
966
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
967
|
+
const results = await axe($.html());
|
|
968
|
+
expect(results).toHaveNoViolations();
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
test('THEN: it renders the chart container with the correct data attributes', () => {
|
|
972
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('column');
|
|
973
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('alternate');
|
|
974
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Column Chart');
|
|
975
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('column-chart-123');
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
test('THEN: it does NOT render optional fields', () => {
|
|
979
|
+
expect($('figcaption').length).toBe(0);
|
|
980
|
+
expect($('.ons-chart__download-title').length).toBe(0);
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
test('THEN: it includes the Highcharts JSON config', () => {
|
|
984
|
+
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
985
|
+
expect(configScript).toContain('"text":"X Axis Title"');
|
|
986
|
+
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
987
|
+
});
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
describe('GIVEN: Params: legend', () => {
|
|
992
|
+
describe('WHEN: legend is true', () => {
|
|
993
|
+
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_COLUMN_CHART_PARAMS, legend: true }));
|
|
588
994
|
|
|
589
|
-
test('THEN: it renders the legend
|
|
995
|
+
test('THEN: it renders the legend', () => {
|
|
996
|
+
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
997
|
+
expect(configScript).toContain('"legend":{"enabled":true}');
|
|
998
|
+
});
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
describe('WHEN: legend is false', () => {
|
|
1002
|
+
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_COLUMN_CHART_PARAMS, legend: false }));
|
|
1003
|
+
|
|
1004
|
+
test('THEN: it disables the legend', () => {
|
|
590
1005
|
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
591
|
-
expect(configScript).toContain('"enabled":
|
|
1006
|
+
expect(configScript).toContain('"legend":{"enabled":false}');
|
|
592
1007
|
});
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
describe('WHEN: legend is not provided', () => {
|
|
1011
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
593
1012
|
|
|
594
|
-
test('THEN: it
|
|
1013
|
+
test('THEN: it defaults to enabled', () => {
|
|
595
1014
|
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
1015
|
+
expect(configScript).toContain('"legend":{"enabled":true}');
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
describe('GIVEN: Params: xAxis', () => {
|
|
1021
|
+
describe('WHEN: xAxis options are provided', () => {
|
|
1022
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
1023
|
+
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
1024
|
+
|
|
1025
|
+
test('THEN: it renders the xAxis correctly', () => {
|
|
596
1026
|
expect(configScript).toContain('"text":"X Axis Title"');
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
1032
|
+
describe('WHEN: yAxis options are provided', () => {
|
|
1033
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
1034
|
+
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
1035
|
+
|
|
1036
|
+
test('THEN: it renders the yAxis correctly', () => {
|
|
597
1037
|
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
598
1038
|
});
|
|
599
1039
|
});
|
|
1040
|
+
describe('WHEN: yAxis min and max are provided', () => {
|
|
1041
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
1042
|
+
const params = {
|
|
1043
|
+
id: 'test-chart',
|
|
1044
|
+
title: 'Test Chart',
|
|
1045
|
+
xAxis: {
|
|
1046
|
+
title: 'X Axis Title',
|
|
1047
|
+
categories: ['A', 'B', 'C'],
|
|
1048
|
+
type: 'linear',
|
|
1049
|
+
labelFormat: '{value}',
|
|
1050
|
+
},
|
|
1051
|
+
chartType: 'column',
|
|
1052
|
+
yAxis: {
|
|
1053
|
+
title: 'Y Axis Title',
|
|
1054
|
+
labelFormat: '{value}',
|
|
1055
|
+
min: 0,
|
|
1056
|
+
max: 100,
|
|
1057
|
+
startOnTick: false,
|
|
1058
|
+
endOnTick: true,
|
|
1059
|
+
},
|
|
1060
|
+
series: [],
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1064
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1065
|
+
|
|
1066
|
+
expect(configScript).toContain('"min":0');
|
|
1067
|
+
expect(configScript).toContain('"max":100');
|
|
1068
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
1069
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
describe('WHEN: yAxis min and max are not provided', () => {
|
|
1073
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
1074
|
+
const params = {
|
|
1075
|
+
id: 'test-chart',
|
|
1076
|
+
title: 'Test Chart',
|
|
1077
|
+
xAxis: {
|
|
1078
|
+
title: 'X Axis Title',
|
|
1079
|
+
categories: ['A', 'B', 'C'],
|
|
1080
|
+
type: 'linear',
|
|
1081
|
+
labelFormat: '{value}',
|
|
1082
|
+
},
|
|
1083
|
+
chartType: 'column',
|
|
1084
|
+
yAxis: {
|
|
1085
|
+
title: 'Y Axis Title',
|
|
1086
|
+
labelFormat: '{value}',
|
|
1087
|
+
min: undefined,
|
|
1088
|
+
max: undefined,
|
|
1089
|
+
startOnTick: undefined,
|
|
1090
|
+
endOnTick: undefined,
|
|
1091
|
+
},
|
|
1092
|
+
series: [],
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1096
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1097
|
+
|
|
1098
|
+
const config = JSON.parse(configScript);
|
|
1099
|
+
|
|
1100
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
1101
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
1102
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
1103
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
600
1106
|
});
|
|
601
1107
|
|
|
602
|
-
describe('GIVEN: Params:
|
|
1108
|
+
describe('GIVEN: Params: percentageHeightDesktop', () => {
|
|
603
1109
|
describe('WHEN: percentage height desktop is provided', () => {
|
|
604
1110
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
605
1111
|
test('THEN: it includes correct percentage height desktop', () => {
|
|
@@ -608,7 +1114,7 @@ describe('Macro: Chart', () => {
|
|
|
608
1114
|
});
|
|
609
1115
|
});
|
|
610
1116
|
|
|
611
|
-
describe('GIVEN: Params:
|
|
1117
|
+
describe('GIVEN: Params: percentageHeightMobile', () => {
|
|
612
1118
|
describe('WHEN: percentage height mobile is provided', () => {
|
|
613
1119
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_PARAMS));
|
|
614
1120
|
test('THEN: it includes correct percentage height mobile', () => {
|
|
@@ -617,7 +1123,7 @@ describe('Macro: Chart', () => {
|
|
|
617
1123
|
});
|
|
618
1124
|
});
|
|
619
1125
|
|
|
620
|
-
describe('GIVEN: Params:
|
|
1126
|
+
describe('GIVEN: Params: caption', () => {
|
|
621
1127
|
describe('WHEN: caption is provided', () => {
|
|
622
1128
|
const $ = cheerio.load(
|
|
623
1129
|
renderComponent('chart', {
|
|
@@ -632,7 +1138,7 @@ describe('Macro: Chart', () => {
|
|
|
632
1138
|
});
|
|
633
1139
|
});
|
|
634
1140
|
|
|
635
|
-
describe('GIVEN: Params:
|
|
1141
|
+
describe('GIVEN: Params: description', () => {
|
|
636
1142
|
describe('WHEN: description is provided', () => {
|
|
637
1143
|
const $ = cheerio.load(
|
|
638
1144
|
renderComponent('chart', {
|
|
@@ -647,8 +1153,8 @@ describe('Macro: Chart', () => {
|
|
|
647
1153
|
});
|
|
648
1154
|
});
|
|
649
1155
|
|
|
650
|
-
describe('GIVEN: Params:
|
|
651
|
-
describe('WHEN: download object
|
|
1156
|
+
describe('GIVEN: Params: download', () => {
|
|
1157
|
+
describe('WHEN: download object is provided', () => {
|
|
652
1158
|
const $ = cheerio.load(
|
|
653
1159
|
renderComponent('chart', {
|
|
654
1160
|
...EXAMPLE_COLUMN_CHART_PARAMS,
|
|
@@ -674,7 +1180,7 @@ describe('Macro: Chart', () => {
|
|
|
674
1180
|
});
|
|
675
1181
|
});
|
|
676
1182
|
|
|
677
|
-
describe('GIVEN:
|
|
1183
|
+
describe('GIVEN: Params: useStackedLayout', () => {
|
|
678
1184
|
describe('WHEN: Stacked layout is enabled', () => {
|
|
679
1185
|
const $ = cheerio.load(
|
|
680
1186
|
renderComponent('chart', {
|
|
@@ -692,69 +1198,8 @@ describe('Macro: Chart', () => {
|
|
|
692
1198
|
});
|
|
693
1199
|
});
|
|
694
1200
|
});
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
describe('FOR: Line chart with annotations', () => {
|
|
698
|
-
describe('GIVEN: Params: Annotations', () => {
|
|
699
|
-
describe('WHEN: annotations params are provided', () => {
|
|
700
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_ANNOTATIONS_PARAMS));
|
|
701
|
-
|
|
702
|
-
test('THEN: it passes jest-axe checks', async () => {
|
|
703
|
-
const results = await axe($.html());
|
|
704
|
-
expect(results).toHaveNoViolations();
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
test('THEN: it renders the footnotes', () => {
|
|
708
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
709
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
710
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('2');
|
|
711
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('Another test annotation');
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
715
|
-
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
test('THEN: it includes the Annotations JSON config', () => {
|
|
719
|
-
const configScript = $(`script[data-highcharts-annotations--line-chart-annotations-123]`).html();
|
|
720
|
-
expect(configScript).toContain('"text":"A test annotation"');
|
|
721
|
-
expect(configScript).toContain('"point":{"x":10,"y":1.3}');
|
|
722
|
-
expect(configScript).toContain('"labelOffsetX":10,"labelOffsetY":-50');
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
describe('FOR: Bar chart with annotations', () => {
|
|
729
|
-
describe('GIVEN: Params: Annotations', () => {
|
|
730
|
-
describe('WHEN: annotations params are provided', () => {
|
|
731
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_BAR_CHART_WITH_ANNOTATIONS_PARAMS));
|
|
732
|
-
test('THEN: it passes jest-axe checks', async () => {
|
|
733
|
-
const results = await axe($.html());
|
|
734
|
-
expect(results).toHaveNoViolations();
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
test('THEN: it renders the footnotes', () => {
|
|
738
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('1');
|
|
739
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test annotation');
|
|
740
|
-
});
|
|
741
|
-
|
|
742
|
-
test('THEN: the footnotes are hidden from screen readers', () => {
|
|
743
|
-
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
test('THEN: it includes the Annotations JSON config', () => {
|
|
747
|
-
const configScript = $(`script[data-highcharts-annotations--bar-chart-annotations-123]`).html();
|
|
748
|
-
expect(configScript).toContain('"text":"A test annotation"');
|
|
749
|
-
expect(configScript).toContain('"point":{"x":2,"y":3}');
|
|
750
|
-
expect(configScript).toContain('"labelOffsetX":10,"labelOffsetY":-50');
|
|
751
|
-
});
|
|
752
|
-
});
|
|
753
|
-
});
|
|
754
|
-
});
|
|
755
1201
|
|
|
756
|
-
|
|
757
|
-
describe('GIVEN: Params: Annotations', () => {
|
|
1202
|
+
describe('GIVEN: Params: annotations', () => {
|
|
758
1203
|
describe('WHEN: annotations params are provided', () => {
|
|
759
1204
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_CHART_WITH_ANNOTATIONS_PARAMS));
|
|
760
1205
|
|
|
@@ -772,7 +1217,7 @@ describe('Macro: Chart', () => {
|
|
|
772
1217
|
expect($('.ons-chart__annotations-footnotes').attr('aria-hidden')).toBe('true');
|
|
773
1218
|
});
|
|
774
1219
|
|
|
775
|
-
test('THEN: it includes the
|
|
1220
|
+
test('THEN: it includes the annotations JSON config', () => {
|
|
776
1221
|
const configScript = $(`script[data-highcharts-annotations--column-chart-annotations-123]`).html();
|
|
777
1222
|
expect(configScript).toContain('"text":"A test annotation"');
|
|
778
1223
|
expect(configScript).toContain('"point":{"x":11,"y":31.8}');
|
|
@@ -780,11 +1225,9 @@ describe('Macro: Chart', () => {
|
|
|
780
1225
|
});
|
|
781
1226
|
});
|
|
782
1227
|
});
|
|
783
|
-
});
|
|
784
1228
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
describe('WHEN: required params are provided', () => {
|
|
1229
|
+
describe('GIVEN: Params: series', () => {
|
|
1230
|
+
describe('WHEN: seriesType is line and required params are provided', () => {
|
|
788
1231
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS));
|
|
789
1232
|
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
790
1233
|
|
|
@@ -811,7 +1254,8 @@ describe('Macro: Chart', () => {
|
|
|
811
1254
|
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
812
1255
|
});
|
|
813
1256
|
});
|
|
814
|
-
|
|
1257
|
+
|
|
1258
|
+
describe('WHEN: seriesType is line and more than one line is provided', () => {
|
|
815
1259
|
const $ = cheerio.load(
|
|
816
1260
|
renderComponent('chart', {
|
|
817
1261
|
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
@@ -829,78 +1273,8 @@ describe('Macro: Chart', () => {
|
|
|
829
1273
|
expect(lineTypeMatches).toBe(1);
|
|
830
1274
|
});
|
|
831
1275
|
});
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
describe('GIVEN: Params: Legend', () => {
|
|
835
|
-
describe('WHEN: legend is enabled', () => {
|
|
836
|
-
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS, legend: false }));
|
|
837
|
-
|
|
838
|
-
test('THEN: it renders the legend', () => {
|
|
839
|
-
const configScript = $(`script[data-highcharts-config--column-chart-123]`).html();
|
|
840
|
-
expect(configScript).toContain('"enabled":false');
|
|
841
|
-
});
|
|
842
|
-
});
|
|
843
|
-
});
|
|
844
|
-
|
|
845
|
-
describe('GIVEN: Params: Caption', () => {
|
|
846
|
-
describe('WHEN: caption is provided', () => {
|
|
847
|
-
const $ = cheerio.load(
|
|
848
|
-
renderComponent('chart', {
|
|
849
|
-
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
850
|
-
caption: 'This is an example caption for the chart.',
|
|
851
|
-
}),
|
|
852
|
-
);
|
|
853
|
-
|
|
854
|
-
test('THEN: it renders the caption when provided', () => {
|
|
855
|
-
expect($('figcaption').text()).toBe('This is an example caption for the chart.');
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
describe('GIVEN: Params: Description', () => {
|
|
861
|
-
describe('WHEN: description is provided', () => {
|
|
862
|
-
const $ = cheerio.load(
|
|
863
|
-
renderComponent('chart', {
|
|
864
|
-
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
865
|
-
description: 'An accessible description for screen readers.',
|
|
866
|
-
}),
|
|
867
|
-
);
|
|
868
|
-
|
|
869
|
-
test('THEN: it renders the description for accessibility', () => {
|
|
870
|
-
expect($('#chart-audio-description-column-chart-123').text()).toBe('An accessible description for screen readers.');
|
|
871
|
-
});
|
|
872
|
-
});
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
describe('GIVEN: Params: Download', () => {
|
|
876
|
-
describe('WHEN: download object is provided', () => {
|
|
877
|
-
const $ = cheerio.load(
|
|
878
|
-
renderComponent('chart', {
|
|
879
|
-
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
880
|
-
download: {
|
|
881
|
-
title: 'Download Chart Data',
|
|
882
|
-
itemsList: [
|
|
883
|
-
{ text: 'Download as PNG', url: 'https://example.com/chart.png' },
|
|
884
|
-
{ text: 'Download as CSV', url: 'https://example.com/chart.csv' },
|
|
885
|
-
],
|
|
886
|
-
},
|
|
887
|
-
}),
|
|
888
|
-
);
|
|
889
|
-
|
|
890
|
-
test('THEN: it renders the download section correctly', () => {
|
|
891
|
-
expect($('.ons-chart__download-title').text()).toBe('Download Chart Data');
|
|
892
|
-
|
|
893
|
-
const downloadLinks = $('.ons-chart__download-title').next().find('li a');
|
|
894
|
-
expect(downloadLinks.eq(0).text()).toBe('Download as PNG');
|
|
895
|
-
expect(downloadLinks.eq(0).attr('href')).toBe('https://example.com/chart.png');
|
|
896
|
-
expect(downloadLinks.eq(1).text()).toBe('Download as CSV');
|
|
897
|
-
expect(downloadLinks.eq(1).attr('href')).toBe('https://example.com/chart.csv');
|
|
898
|
-
});
|
|
899
|
-
});
|
|
900
|
-
});
|
|
901
1276
|
|
|
902
|
-
|
|
903
|
-
describe('WHEN: a series has an invalid type', () => {
|
|
1277
|
+
describe('WHEN: a series item has an invalid type', () => {
|
|
904
1278
|
const invalidTypeParams = {
|
|
905
1279
|
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
906
1280
|
series: [
|
|
@@ -919,23 +1293,6 @@ describe('Macro: Chart', () => {
|
|
|
919
1293
|
});
|
|
920
1294
|
});
|
|
921
1295
|
});
|
|
922
|
-
|
|
923
|
-
describe('GIVEN: Params: ChartType', () => {
|
|
924
|
-
describe('WHEN: chartType is not compatible with line series', () => {
|
|
925
|
-
const params = {
|
|
926
|
-
...EXAMPLE_COLUMN_WITH_LINE_CHART_PARAMS,
|
|
927
|
-
chartType: 'bar',
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
931
|
-
const configScript = $('script[data-highcharts-config--column-chart-123]').html();
|
|
932
|
-
|
|
933
|
-
test('THEN: it falls back to chartType and does not include "line" series', () => {
|
|
934
|
-
expect(configScript).not.toContain('"type":"line"');
|
|
935
|
-
expect(configScript).toContain('"type":"bar"');
|
|
936
|
-
});
|
|
937
|
-
});
|
|
938
|
-
});
|
|
939
1296
|
});
|
|
940
1297
|
|
|
941
1298
|
describe('FOR: Scatter chart', () => {
|
|
@@ -956,38 +1313,175 @@ describe('Macro: Chart', () => {
|
|
|
956
1313
|
});
|
|
957
1314
|
});
|
|
958
1315
|
});
|
|
959
|
-
});
|
|
960
|
-
|
|
961
|
-
describe('FOR: Area Chart', () => {
|
|
962
|
-
describe('GIVEN: Params: required', () => {
|
|
963
|
-
describe('WHEN: required params are provided', () => {
|
|
964
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_AREA_CHART_PARAMS));
|
|
965
|
-
const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
|
|
966
|
-
|
|
967
|
-
test('THEN: it passes jest-axe checks', async () => {
|
|
968
|
-
const results = await axe($.html());
|
|
969
|
-
expect(results).toHaveNoViolations();
|
|
970
|
-
});
|
|
971
1316
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1317
|
+
describe('GIVEN: Params: xAxis', () => {
|
|
1318
|
+
describe('WHEN: xAxis options are provided', () => {
|
|
1319
|
+
test('THEN: xAxis min and max are included in config', () => {
|
|
1320
|
+
const params = {
|
|
1321
|
+
id: 'test-chart',
|
|
1322
|
+
title: 'Test Chart',
|
|
1323
|
+
chartType: 'scatter',
|
|
1324
|
+
xAxis: {
|
|
1325
|
+
title: 'X Axis Title',
|
|
1326
|
+
categories: ['A', 'B', 'C'],
|
|
1327
|
+
type: 'linear',
|
|
1328
|
+
labelFormat: '{value}',
|
|
1329
|
+
min: 1,
|
|
1330
|
+
max: 10,
|
|
1331
|
+
startOnTick: true,
|
|
1332
|
+
endOnTick: false,
|
|
1333
|
+
},
|
|
1334
|
+
yAxis: {
|
|
1335
|
+
title: 'Y Axis Title',
|
|
1336
|
+
labelFormat: '{value}',
|
|
1337
|
+
},
|
|
1338
|
+
series: [],
|
|
1339
|
+
};
|
|
975
1340
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
|
|
979
|
-
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Area Chart');
|
|
980
|
-
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('area-chart-123');
|
|
981
|
-
});
|
|
1341
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1342
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
982
1343
|
|
|
983
|
-
|
|
984
|
-
expect(configScript).toContain('"
|
|
985
|
-
expect(configScript).toContain('"
|
|
1344
|
+
expect(configScript).toContain('"min":1');
|
|
1345
|
+
expect(configScript).toContain('"max":10');
|
|
1346
|
+
expect(configScript).toContain('"startOnTick":true');
|
|
1347
|
+
expect(configScript).toContain('"endOnTick":false');
|
|
986
1348
|
});
|
|
987
1349
|
});
|
|
988
|
-
});
|
|
989
1350
|
|
|
990
|
-
|
|
1351
|
+
describe('WHEN: xAxis options are not provided', () => {
|
|
1352
|
+
test('THEN: xAxis min and max are not included in config', () => {
|
|
1353
|
+
const params = {
|
|
1354
|
+
id: 'test-chart',
|
|
1355
|
+
title: 'Test Chart',
|
|
1356
|
+
chartType: 'scatter',
|
|
1357
|
+
xAxis: {
|
|
1358
|
+
title: 'X Axis Title',
|
|
1359
|
+
categories: ['A', 'B', 'C'],
|
|
1360
|
+
type: 'linear',
|
|
1361
|
+
labelFormat: '{value}',
|
|
1362
|
+
min: undefined,
|
|
1363
|
+
max: undefined,
|
|
1364
|
+
startOnTick: undefined,
|
|
1365
|
+
endOnTick: undefined,
|
|
1366
|
+
},
|
|
1367
|
+
yAxis: {
|
|
1368
|
+
title: 'Y Axis Title',
|
|
1369
|
+
labelFormat: '{value}',
|
|
1370
|
+
},
|
|
1371
|
+
series: [],
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1375
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1376
|
+
|
|
1377
|
+
const config = JSON.parse(configScript);
|
|
1378
|
+
|
|
1379
|
+
expect(config.xAxis.min).toBeUndefined();
|
|
1380
|
+
expect(config.xAxis.max).toBeUndefined();
|
|
1381
|
+
expect(config.xAxis.startOnTick).toBeUndefined();
|
|
1382
|
+
expect(config.xAxis.endOnTick).toBeUndefined();
|
|
1383
|
+
});
|
|
1384
|
+
});
|
|
1385
|
+
describe('WHEN: yAxis options are provided', () => {
|
|
1386
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
1387
|
+
const params = {
|
|
1388
|
+
id: 'test-chart',
|
|
1389
|
+
title: 'Test Chart',
|
|
1390
|
+
xAxis: {
|
|
1391
|
+
title: 'X Axis Title',
|
|
1392
|
+
categories: ['A', 'B', 'C'],
|
|
1393
|
+
type: 'linear',
|
|
1394
|
+
labelFormat: '{value}',
|
|
1395
|
+
},
|
|
1396
|
+
chartType: 'scatter',
|
|
1397
|
+
yAxis: {
|
|
1398
|
+
title: 'Y Axis Title',
|
|
1399
|
+
labelFormat: '{value}',
|
|
1400
|
+
min: 0,
|
|
1401
|
+
max: 100,
|
|
1402
|
+
startOnTick: false,
|
|
1403
|
+
endOnTick: true,
|
|
1404
|
+
},
|
|
1405
|
+
series: [],
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1409
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1410
|
+
|
|
1411
|
+
expect(configScript).toContain('"min":0');
|
|
1412
|
+
expect(configScript).toContain('"max":100');
|
|
1413
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
1414
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
1415
|
+
});
|
|
1416
|
+
});
|
|
1417
|
+
|
|
1418
|
+
describe('WHEN: yAxis options are not provided', () => {
|
|
1419
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
1420
|
+
const params = {
|
|
1421
|
+
id: 'test-chart',
|
|
1422
|
+
title: 'Test Chart',
|
|
1423
|
+
xAxis: {
|
|
1424
|
+
title: 'X Axis Title',
|
|
1425
|
+
categories: ['A', 'B', 'C'],
|
|
1426
|
+
type: 'linear',
|
|
1427
|
+
labelFormat: '{value}',
|
|
1428
|
+
},
|
|
1429
|
+
chartType: 'scatter',
|
|
1430
|
+
yAxis: {
|
|
1431
|
+
title: 'Y Axis Title',
|
|
1432
|
+
labelFormat: '{value}',
|
|
1433
|
+
min: undefined,
|
|
1434
|
+
max: undefined,
|
|
1435
|
+
startOnTick: undefined,
|
|
1436
|
+
endOnTick: undefined,
|
|
1437
|
+
},
|
|
1438
|
+
series: [],
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1442
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1443
|
+
|
|
1444
|
+
const config = JSON.parse(configScript);
|
|
1445
|
+
|
|
1446
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
1447
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
1448
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
1449
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
1450
|
+
});
|
|
1451
|
+
});
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
describe('FOR: Area Chart', () => {
|
|
1456
|
+
describe('GIVEN: Params: required', () => {
|
|
1457
|
+
describe('WHEN: required params are provided', () => {
|
|
1458
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_AREA_CHART_PARAMS));
|
|
1459
|
+
const configScript = $(`script[data-highcharts-config--area-chart-123]`).html();
|
|
1460
|
+
|
|
1461
|
+
test('THEN: it passes jest-axe checks', async () => {
|
|
1462
|
+
const results = await axe($.html());
|
|
1463
|
+
expect(results).toHaveNoViolations();
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
test('THEN: it includes at least one area series', () => {
|
|
1467
|
+
expect(configScript).toContain('"type":"area"');
|
|
1468
|
+
});
|
|
1469
|
+
|
|
1470
|
+
test('THEN: it renders the chart container with correct data attributes', () => {
|
|
1471
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-type')).toBe('area');
|
|
1472
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-theme')).toBe('primary');
|
|
1473
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-title')).toBe('Example Area Chart');
|
|
1474
|
+
expect($('[data-highcharts-base-chart]').attr('data-highcharts-id')).toBe('area-chart-123');
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
test('THEN: it includes the Highcharts JSON config', () => {
|
|
1478
|
+
expect(configScript).toContain('"text":"X Axis Title"');
|
|
1479
|
+
expect(configScript).toContain('"text":"Y Axis Title"');
|
|
1480
|
+
});
|
|
1481
|
+
});
|
|
1482
|
+
});
|
|
1483
|
+
|
|
1484
|
+
describe('GIVEN: Params: legend', () => {
|
|
991
1485
|
describe('WHEN: legend is enabled', () => {
|
|
992
1486
|
const $ = cheerio.load(renderComponent('chart', { ...EXAMPLE_AREA_CHART_PARAMS, legend: false }));
|
|
993
1487
|
|
|
@@ -998,7 +1492,7 @@ describe('Macro: Chart', () => {
|
|
|
998
1492
|
});
|
|
999
1493
|
});
|
|
1000
1494
|
|
|
1001
|
-
describe('GIVEN: Params:
|
|
1495
|
+
describe('GIVEN: Params: caption', () => {
|
|
1002
1496
|
describe('WHEN: caption is provided', () => {
|
|
1003
1497
|
const $ = cheerio.load(
|
|
1004
1498
|
renderComponent('chart', {
|
|
@@ -1013,7 +1507,7 @@ describe('Macro: Chart', () => {
|
|
|
1013
1507
|
});
|
|
1014
1508
|
});
|
|
1015
1509
|
|
|
1016
|
-
describe('GIVEN: Params:
|
|
1510
|
+
describe('GIVEN: Params: description', () => {
|
|
1017
1511
|
describe('WHEN: description is provided', () => {
|
|
1018
1512
|
const $ = cheerio.load(
|
|
1019
1513
|
renderComponent('chart', {
|
|
@@ -1028,8 +1522,8 @@ describe('Macro: Chart', () => {
|
|
|
1028
1522
|
});
|
|
1029
1523
|
});
|
|
1030
1524
|
|
|
1031
|
-
describe('GIVEN: Params:
|
|
1032
|
-
describe('WHEN: download object
|
|
1525
|
+
describe('GIVEN: Params: download', () => {
|
|
1526
|
+
describe('WHEN: download object is provided', () => {
|
|
1033
1527
|
const $ = cheerio.load(
|
|
1034
1528
|
renderComponent('chart', {
|
|
1035
1529
|
...EXAMPLE_AREA_CHART_PARAMS,
|
|
@@ -1055,7 +1549,7 @@ describe('Macro: Chart', () => {
|
|
|
1055
1549
|
});
|
|
1056
1550
|
});
|
|
1057
1551
|
|
|
1058
|
-
describe('GIVEN: Params:
|
|
1552
|
+
describe('GIVEN: Params: footnotes', () => {
|
|
1059
1553
|
describe('WHEN: footnotes are provided', () => {
|
|
1060
1554
|
const $ = cheerio.load(
|
|
1061
1555
|
renderComponent('chart', {
|
|
@@ -1074,6 +1568,75 @@ describe('Macro: Chart', () => {
|
|
|
1074
1568
|
});
|
|
1075
1569
|
});
|
|
1076
1570
|
});
|
|
1571
|
+
|
|
1572
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
1573
|
+
describe('WHEN: yAxis options are provided', () => {
|
|
1574
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
1575
|
+
const params = {
|
|
1576
|
+
id: 'test-chart',
|
|
1577
|
+
title: 'Test Chart',
|
|
1578
|
+
xAxis: {
|
|
1579
|
+
title: 'X Axis Title',
|
|
1580
|
+
categories: ['A', 'B', 'C'],
|
|
1581
|
+
type: 'linear',
|
|
1582
|
+
labelFormat: '{value}',
|
|
1583
|
+
},
|
|
1584
|
+
chartType: 'area',
|
|
1585
|
+
yAxis: {
|
|
1586
|
+
title: 'Y Axis Title',
|
|
1587
|
+
labelFormat: '{value}',
|
|
1588
|
+
min: 0,
|
|
1589
|
+
max: 100,
|
|
1590
|
+
startOnTick: false,
|
|
1591
|
+
endOnTick: true,
|
|
1592
|
+
},
|
|
1593
|
+
series: [],
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1597
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1598
|
+
|
|
1599
|
+
expect(configScript).toContain('"min":0');
|
|
1600
|
+
expect(configScript).toContain('"max":100');
|
|
1601
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
1602
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
1603
|
+
});
|
|
1604
|
+
});
|
|
1605
|
+
describe('WHEN: yAxis options are not provided', () => {
|
|
1606
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
1607
|
+
const params = {
|
|
1608
|
+
id: 'test-chart',
|
|
1609
|
+
title: 'Test Chart',
|
|
1610
|
+
xAxis: {
|
|
1611
|
+
title: 'X Axis Title',
|
|
1612
|
+
categories: ['A', 'B', 'C'],
|
|
1613
|
+
type: 'linear',
|
|
1614
|
+
labelFormat: '{value}',
|
|
1615
|
+
},
|
|
1616
|
+
chartType: 'area',
|
|
1617
|
+
yAxis: {
|
|
1618
|
+
title: 'Y Axis Title',
|
|
1619
|
+
labelFormat: '{value}',
|
|
1620
|
+
min: undefined,
|
|
1621
|
+
max: undefined,
|
|
1622
|
+
startOnTick: undefined,
|
|
1623
|
+
endOnTick: undefined,
|
|
1624
|
+
},
|
|
1625
|
+
series: [],
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1629
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1630
|
+
|
|
1631
|
+
const config = JSON.parse(configScript);
|
|
1632
|
+
|
|
1633
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
1634
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
1635
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
1636
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
1637
|
+
});
|
|
1638
|
+
});
|
|
1639
|
+
});
|
|
1077
1640
|
});
|
|
1078
1641
|
|
|
1079
1642
|
describe('FOR: Boxplot Chart', () => {
|
|
@@ -1106,7 +1669,7 @@ describe('Macro: Chart', () => {
|
|
|
1106
1669
|
});
|
|
1107
1670
|
});
|
|
1108
1671
|
|
|
1109
|
-
describe('GIVEN: Params:
|
|
1672
|
+
describe('GIVEN: Params: legend', () => {
|
|
1110
1673
|
describe('WHEN: both labels are provided and legend is enabled', () => {
|
|
1111
1674
|
const $ = cheerio.load(
|
|
1112
1675
|
renderComponent('chart', {
|
|
@@ -1189,7 +1752,7 @@ describe('Macro: Chart', () => {
|
|
|
1189
1752
|
});
|
|
1190
1753
|
});
|
|
1191
1754
|
|
|
1192
|
-
describe('GIVEN: Params:
|
|
1755
|
+
describe('GIVEN: Params: description', () => {
|
|
1193
1756
|
describe('WHEN: description is provided', () => {
|
|
1194
1757
|
const accessibleDescription = 'An accessible description for screen readers.';
|
|
1195
1758
|
const $ = cheerio.load(
|
|
@@ -1205,13 +1768,12 @@ describe('Macro: Chart', () => {
|
|
|
1205
1768
|
});
|
|
1206
1769
|
});
|
|
1207
1770
|
|
|
1208
|
-
describe('GIVEN: Params:
|
|
1209
|
-
describe('WHEN:
|
|
1771
|
+
describe('GIVEN: Params: estimateLineLabel', () => {
|
|
1772
|
+
describe('WHEN: estimateLineLabel is provided', () => {
|
|
1210
1773
|
const $ = cheerio.load(
|
|
1211
1774
|
renderComponent('chart', {
|
|
1212
1775
|
...EXAMPLE_BOXPLOT_CHART_PARAMS,
|
|
1213
1776
|
estimateLineLabel: 'Estimated value',
|
|
1214
|
-
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
1215
1777
|
}),
|
|
1216
1778
|
);
|
|
1217
1779
|
|
|
@@ -1219,6 +1781,17 @@ describe('Macro: Chart', () => {
|
|
|
1219
1781
|
const baseChart = $('[data-highcharts-base-chart]');
|
|
1220
1782
|
expect(baseChart.attr('data-highcharts-estimate-line-label')).toBe('Estimated value');
|
|
1221
1783
|
});
|
|
1784
|
+
});
|
|
1785
|
+
});
|
|
1786
|
+
|
|
1787
|
+
describe('GIVEN: Params: uncertaintyRangeLabel', () => {
|
|
1788
|
+
describe('WHEN: uncertaintyRangeLabel is provided', () => {
|
|
1789
|
+
const $ = cheerio.load(
|
|
1790
|
+
renderComponent('chart', {
|
|
1791
|
+
...EXAMPLE_BOXPLOT_CHART_PARAMS,
|
|
1792
|
+
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
1793
|
+
}),
|
|
1794
|
+
);
|
|
1222
1795
|
|
|
1223
1796
|
test('THEN: it sets the uncertainty range label as a data attribute', () => {
|
|
1224
1797
|
const baseChart = $('[data-highcharts-base-chart]');
|
|
@@ -1226,10 +1799,79 @@ describe('Macro: Chart', () => {
|
|
|
1226
1799
|
});
|
|
1227
1800
|
});
|
|
1228
1801
|
});
|
|
1802
|
+
|
|
1803
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
1804
|
+
describe('WHEN: yAxis min and max are provided', () => {
|
|
1805
|
+
test('THEN: yAxis min and max are included in config ', () => {
|
|
1806
|
+
const params = {
|
|
1807
|
+
id: 'test-chart',
|
|
1808
|
+
title: 'Test Chart',
|
|
1809
|
+
xAxis: {
|
|
1810
|
+
title: 'X Axis Title',
|
|
1811
|
+
categories: ['A', 'B', 'C'],
|
|
1812
|
+
type: 'linear',
|
|
1813
|
+
labelFormat: '{value}',
|
|
1814
|
+
},
|
|
1815
|
+
chartType: 'boxplot',
|
|
1816
|
+
yAxis: {
|
|
1817
|
+
title: 'Y Axis Title',
|
|
1818
|
+
labelFormat: '{value}',
|
|
1819
|
+
min: 0,
|
|
1820
|
+
max: 100,
|
|
1821
|
+
startOnTick: false,
|
|
1822
|
+
endOnTick: true,
|
|
1823
|
+
},
|
|
1824
|
+
series: [],
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1827
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1828
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1829
|
+
|
|
1830
|
+
expect(configScript).toContain('"min":0');
|
|
1831
|
+
expect(configScript).toContain('"max":100');
|
|
1832
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
1833
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
1834
|
+
});
|
|
1835
|
+
});
|
|
1836
|
+
describe('WHEN: yAxis min and max are not provided', () => {
|
|
1837
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
1838
|
+
const params = {
|
|
1839
|
+
id: 'test-chart',
|
|
1840
|
+
title: 'Test Chart',
|
|
1841
|
+
xAxis: {
|
|
1842
|
+
title: 'X Axis Title',
|
|
1843
|
+
categories: ['A', 'B', 'C'],
|
|
1844
|
+
type: 'linear',
|
|
1845
|
+
labelFormat: '{value}',
|
|
1846
|
+
},
|
|
1847
|
+
chartType: 'boxplot',
|
|
1848
|
+
yAxis: {
|
|
1849
|
+
title: 'Y Axis Title',
|
|
1850
|
+
labelFormat: '{value}',
|
|
1851
|
+
min: undefined,
|
|
1852
|
+
max: undefined,
|
|
1853
|
+
startOnTick: undefined,
|
|
1854
|
+
endOnTick: undefined,
|
|
1855
|
+
},
|
|
1856
|
+
series: [],
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1860
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1861
|
+
|
|
1862
|
+
const config = JSON.parse(configScript);
|
|
1863
|
+
|
|
1864
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
1865
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
1866
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
1867
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
1868
|
+
});
|
|
1869
|
+
});
|
|
1870
|
+
});
|
|
1229
1871
|
});
|
|
1230
1872
|
|
|
1231
1873
|
describe('FOR: Column Range Chart', () => {
|
|
1232
|
-
describe('GIVEN: Params:
|
|
1874
|
+
describe('GIVEN: Params: required', () => {
|
|
1233
1875
|
describe('WHEN: required params are provided', () => {
|
|
1234
1876
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_COLUMN_RANGE_CHART_PARAMS));
|
|
1235
1877
|
const configScript = $(`script[data-highcharts-config--column-range-chart-123]`).html();
|
|
@@ -1255,10 +1897,79 @@ describe('Macro: Chart', () => {
|
|
|
1255
1897
|
});
|
|
1256
1898
|
});
|
|
1257
1899
|
});
|
|
1900
|
+
|
|
1901
|
+
describe('GIVEN: Params: yAxis', () => {
|
|
1902
|
+
describe('WHEN: yAxis min and max are provided', () => {
|
|
1903
|
+
test('THEN: yAxis min and max are included in config', () => {
|
|
1904
|
+
const params = {
|
|
1905
|
+
id: 'test-chart',
|
|
1906
|
+
title: 'Test Chart',
|
|
1907
|
+
xAxis: {
|
|
1908
|
+
title: 'X Axis Title',
|
|
1909
|
+
categories: ['A', 'B', 'C'],
|
|
1910
|
+
type: 'linear',
|
|
1911
|
+
labelFormat: '{value}',
|
|
1912
|
+
},
|
|
1913
|
+
chartType: 'columnrange',
|
|
1914
|
+
yAxis: {
|
|
1915
|
+
title: 'Y Axis Title',
|
|
1916
|
+
labelFormat: '{value}',
|
|
1917
|
+
min: 0,
|
|
1918
|
+
max: 100,
|
|
1919
|
+
startOnTick: false,
|
|
1920
|
+
endOnTick: true,
|
|
1921
|
+
},
|
|
1922
|
+
series: [],
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1926
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1927
|
+
|
|
1928
|
+
expect(configScript).toContain('"min":0');
|
|
1929
|
+
expect(configScript).toContain('"max":100');
|
|
1930
|
+
expect(configScript).toContain('"startOnTick":false');
|
|
1931
|
+
expect(configScript).toContain('"endOnTick":true');
|
|
1932
|
+
});
|
|
1933
|
+
});
|
|
1934
|
+
describe('WHEN: yAxis min and max are not provided', () => {
|
|
1935
|
+
test('THEN: yAxis min and max are not included in config', () => {
|
|
1936
|
+
const params = {
|
|
1937
|
+
id: 'test-chart',
|
|
1938
|
+
title: 'Test Chart',
|
|
1939
|
+
xAxis: {
|
|
1940
|
+
title: 'X Axis Title',
|
|
1941
|
+
categories: ['A', 'B', 'C'],
|
|
1942
|
+
type: 'linear',
|
|
1943
|
+
labelFormat: '{value}',
|
|
1944
|
+
},
|
|
1945
|
+
chartType: 'columnrange',
|
|
1946
|
+
yAxis: {
|
|
1947
|
+
title: 'Y Axis Title',
|
|
1948
|
+
labelFormat: '{value}',
|
|
1949
|
+
min: undefined,
|
|
1950
|
+
max: undefined,
|
|
1951
|
+
startOnTick: undefined,
|
|
1952
|
+
endOnTick: undefined,
|
|
1953
|
+
},
|
|
1954
|
+
series: [],
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const $ = cheerio.load(renderComponent('chart', params));
|
|
1958
|
+
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1959
|
+
|
|
1960
|
+
const config = JSON.parse(configScript);
|
|
1961
|
+
|
|
1962
|
+
expect(config.yAxis.min).toBeUndefined();
|
|
1963
|
+
expect(config.yAxis.max).toBeUndefined();
|
|
1964
|
+
expect(config.yAxis.startOnTick).toBeUndefined();
|
|
1965
|
+
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
1966
|
+
});
|
|
1967
|
+
});
|
|
1968
|
+
});
|
|
1258
1969
|
});
|
|
1259
1970
|
|
|
1260
1971
|
describe('FOR: Invalid Chart', () => {
|
|
1261
|
-
describe('GIVEN:
|
|
1972
|
+
describe('GIVEN: Params: chartType', () => {
|
|
1262
1973
|
describe('WHEN: an invalid chart type is provided', () => {
|
|
1263
1974
|
const $ = cheerio.load(renderComponent('chart', EXAMPLE_INVALID_CHART_PARAMS));
|
|
1264
1975
|
|
|
@@ -1298,443 +2009,240 @@ describe('Macro: Chart', () => {
|
|
|
1298
2009
|
});
|
|
1299
2010
|
});
|
|
1300
2011
|
|
|
1301
|
-
describe('FOR:
|
|
1302
|
-
describe('GIVEN: Params:
|
|
1303
|
-
describe('WHEN:
|
|
1304
|
-
const $ = cheerio.load(renderComponent('chart',
|
|
2012
|
+
describe('FOR: Iframe Chart', () => {
|
|
2013
|
+
describe('GIVEN: Params: required', () => {
|
|
2014
|
+
describe('WHEN: iframeUrl param is provided', () => {
|
|
2015
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_IFRAME_CHART_PARAMS));
|
|
1305
2016
|
|
|
1306
2017
|
test('THEN: it passes jest-axe checks', async () => {
|
|
1307
2018
|
const results = await axe($.html());
|
|
1308
2019
|
expect(results).toHaveNoViolations();
|
|
1309
2020
|
});
|
|
1310
2021
|
|
|
1311
|
-
test('THEN: it
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
expect(configScript).
|
|
2022
|
+
test('THEN: it renders the iframe', () => {
|
|
2023
|
+
expect($('.ons-chart__iframe-wrapper').length).toBe(1);
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
test('THEN: the Highcharts config is not included', () => {
|
|
2027
|
+
const configScript = $(`script[data-highcharts-config--iframe-chart-123]`).html();
|
|
2028
|
+
expect(configScript).toBeNull();
|
|
1318
2029
|
});
|
|
1319
2030
|
});
|
|
1320
2031
|
});
|
|
1321
|
-
});
|
|
1322
2032
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
describe('WHEN: range annotations params are provided', () => {
|
|
2033
|
+
describe('GIVEN: Params: theme', () => {
|
|
2034
|
+
describe('WHEN: theme is provided', () => {
|
|
1326
2035
|
const $ = cheerio.load(
|
|
1327
|
-
renderComponent('chart',
|
|
2036
|
+
renderComponent('chart', {
|
|
2037
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2038
|
+
theme: 'secondary',
|
|
2039
|
+
}),
|
|
1328
2040
|
);
|
|
1329
2041
|
|
|
1330
|
-
test('THEN:
|
|
1331
|
-
|
|
1332
|
-
expect(results).toHaveNoViolations();
|
|
1333
|
-
});
|
|
1334
|
-
|
|
1335
|
-
test('THEN: it includes the range annotations JSON config', () => {
|
|
1336
|
-
const configScript = $(`script[data-highcharts-range-annotations--line-chart-range-annotations-y-axis-123]`).html();
|
|
1337
|
-
expect(configScript).toContain('"text":"A test y axis range annotation with a label width of 250px"');
|
|
1338
|
-
expect(configScript).toContain('"axis":"y"');
|
|
1339
|
-
expect(configScript).toContain('"labelWidth":250');
|
|
2042
|
+
test('THEN: the theme parameter is ignored', () => {
|
|
2043
|
+
expect($('[data-highcharts-theme]').length).toBe(0);
|
|
1340
2044
|
});
|
|
1341
2045
|
});
|
|
1342
2046
|
});
|
|
1343
|
-
});
|
|
1344
|
-
|
|
1345
|
-
describe('FOR: Line chart with range annotation with the label inside', () => {
|
|
1346
|
-
describe('GIVEN: Params: Range annotations', () => {
|
|
1347
|
-
describe('WHEN: range annotations params are provided', () => {
|
|
1348
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_RANGE_ANNOTATION_WITH_LABEL_INSIDE_PARAMS));
|
|
1349
2047
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
2048
|
+
describe('GIVEN: Params: percentageHeightDesktop', () => {
|
|
2049
|
+
describe('WHEN: percentageHeightDesktop is provided', () => {
|
|
2050
|
+
const $ = cheerio.load(
|
|
2051
|
+
renderComponent('chart', {
|
|
2052
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2053
|
+
percentageHeightDesktop: 50,
|
|
2054
|
+
}),
|
|
2055
|
+
);
|
|
1354
2056
|
|
|
1355
|
-
test('THEN:
|
|
1356
|
-
|
|
1357
|
-
`script[data-highcharts-range-annotations--line-chart-range-annotations-label-inside-123]`,
|
|
1358
|
-
).html();
|
|
1359
|
-
expect(configScript).toContain('"text":"A test y axis range annotation with the label inside"');
|
|
1360
|
-
expect(configScript).toContain('"axis":"y"');
|
|
1361
|
-
expect(configScript).toContain('"labelInside":true');
|
|
2057
|
+
test('THEN: the percentageHeightDesktop parameter is ignored', () => {
|
|
2058
|
+
expect($('[data-highcharts-percentage-height-desktop]').length).toBe(0);
|
|
1362
2059
|
});
|
|
1363
2060
|
});
|
|
1364
2061
|
});
|
|
1365
|
-
});
|
|
1366
|
-
|
|
1367
|
-
describe('FOR: Line chart with reference line annotations', () => {
|
|
1368
|
-
describe('GIVEN: Params: Reference line annotations', () => {
|
|
1369
|
-
describe('WHEN: reference line annotations params are provided', () => {
|
|
1370
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_REFERENCE_LINE_ANNOTATIONS_PARAMS));
|
|
1371
2062
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
2063
|
+
describe('GIVEN: Params: percentageHeightMobile', () => {
|
|
2064
|
+
describe('WHEN: percentageHeightMobile is provided', () => {
|
|
2065
|
+
const $ = cheerio.load(
|
|
2066
|
+
renderComponent('chart', {
|
|
2067
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2068
|
+
percentageHeightMobile: 10,
|
|
2069
|
+
}),
|
|
2070
|
+
);
|
|
1376
2071
|
|
|
1377
|
-
test('THEN:
|
|
1378
|
-
|
|
1379
|
-
`script[data-highcharts-reference-line-annotations--line-chart-reference-line-annotations-123]`,
|
|
1380
|
-
).html();
|
|
1381
|
-
expect(configScript).toContain('"text":"A test x axis reference line annotation"');
|
|
1382
|
-
expect(configScript).toContain('"value":34');
|
|
1383
|
-
expect(configScript).toContain('"axis":"x"');
|
|
1384
|
-
expect(configScript).toContain('"text":"A test y axis reference line annotation"');
|
|
1385
|
-
expect(configScript).toContain('"value":12');
|
|
1386
|
-
expect(configScript).toContain('"axis":"y"');
|
|
1387
|
-
expect(configScript).toContain('"labelWidth":100');
|
|
2072
|
+
test('THEN: the percentageHeightMobile parameter is ignored', () => {
|
|
2073
|
+
expect($('[data-highcharts-percentage-height-mobile]').length).toBe(0);
|
|
1388
2074
|
});
|
|
1389
2075
|
});
|
|
1390
2076
|
});
|
|
1391
|
-
});
|
|
1392
|
-
|
|
1393
|
-
describe('FOR: Line chart with mixed annotation types', () => {
|
|
1394
|
-
describe('GIVEN: Params: Mixed annotations', () => {
|
|
1395
|
-
describe('WHEN: mixed annotations params are provided', () => {
|
|
1396
|
-
const $ = cheerio.load(renderComponent('chart', EXAMPLE_LINE_CHART_WITH_MIXED_ANNOTATION_TYPES_PARAMS));
|
|
1397
2077
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
2078
|
+
describe('GIVEN: Params: tickInterval', () => {
|
|
2079
|
+
describe('WHEN: tickIntervalDesktop and tickIntervalMobile are provided', () => {
|
|
2080
|
+
const $ = cheerio.load(
|
|
2081
|
+
renderComponent('chart', {
|
|
2082
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2083
|
+
xAxis: { tickIntervalDesktop: 10, tickIntervalMobile: 5 },
|
|
2084
|
+
yAxis: { tickIntervalDesktop: 10, tickIntervalMobile: 5 },
|
|
2085
|
+
}),
|
|
2086
|
+
);
|
|
1402
2087
|
|
|
1403
|
-
test('THEN:
|
|
1404
|
-
expect($('
|
|
1405
|
-
expect($('
|
|
1406
|
-
expect($('
|
|
1407
|
-
expect($('
|
|
1408
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('3');
|
|
1409
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis range annotation with the label inside');
|
|
1410
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('4');
|
|
1411
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test x axis reference line annotation');
|
|
1412
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('5');
|
|
1413
|
-
expect($('.ons-chart__annotations-footnotes').text()).toContain('A test y axis reference line annotation');
|
|
2088
|
+
test('THEN: the tickIntervalDesktop and tickIntervalMobile parameters are ignored', () => {
|
|
2089
|
+
expect($('[data-highcharts-x-axis-tick-interval-desktop]').length).toBe(0);
|
|
2090
|
+
expect($('[data-highcharts-x-axis-tick-interval-mobile]').length).toBe(0);
|
|
2091
|
+
expect($('[data-highcharts-y-axis-tick-interval-desktop]').length).toBe(0);
|
|
2092
|
+
expect($('[data-highcharts-y-axis-tick-interval-mobile]').length).toBe(0);
|
|
1414
2093
|
});
|
|
1415
2094
|
});
|
|
1416
2095
|
});
|
|
1417
|
-
});
|
|
1418
|
-
|
|
1419
|
-
describe('FOR: Axis Min, Max, startOnTick, endOnTick', () => {
|
|
1420
|
-
const BASE_PARAMS = {
|
|
1421
|
-
id: 'test-chart',
|
|
1422
|
-
title: 'Test Chart',
|
|
1423
|
-
xAxis: {
|
|
1424
|
-
title: 'X Axis Title',
|
|
1425
|
-
categories: ['A', 'B', 'C'],
|
|
1426
|
-
type: 'linear',
|
|
1427
|
-
labelFormat: '{value}',
|
|
1428
|
-
},
|
|
1429
|
-
yAxis: {
|
|
1430
|
-
title: 'Y Axis Title',
|
|
1431
|
-
labelFormat: '{value}',
|
|
1432
|
-
},
|
|
1433
|
-
series: [],
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
describe('GIVEN: chartType supports xAxis min/max (bar, scatter)', () => {
|
|
1437
|
-
test('THEN: xAxis min and max are included in config when provided', () => {
|
|
1438
|
-
const params = {
|
|
1439
|
-
...BASE_PARAMS,
|
|
1440
|
-
chartType: 'scatter',
|
|
1441
|
-
xAxis: {
|
|
1442
|
-
...BASE_PARAMS.xAxis,
|
|
1443
|
-
min: 1,
|
|
1444
|
-
max: 10,
|
|
1445
|
-
startOnTick: true,
|
|
1446
|
-
endOnTick: false,
|
|
1447
|
-
},
|
|
1448
|
-
};
|
|
1449
|
-
|
|
1450
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
1451
|
-
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1452
|
-
|
|
1453
|
-
expect(configScript).toContain('"min":1');
|
|
1454
|
-
expect(configScript).toContain('"max":10');
|
|
1455
|
-
expect(configScript).toContain('"startOnTick":true');
|
|
1456
|
-
expect(configScript).toContain('"endOnTick":false');
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
test('THEN: xAxis min and max are NOT included if not defined', () => {
|
|
1460
|
-
const params = {
|
|
1461
|
-
...BASE_PARAMS,
|
|
1462
|
-
chartType: 'scatter',
|
|
1463
|
-
xAxis: {
|
|
1464
|
-
...BASE_PARAMS.xAxis,
|
|
1465
|
-
min: undefined,
|
|
1466
|
-
max: undefined,
|
|
1467
|
-
startOnTick: undefined,
|
|
1468
|
-
endOnTick: undefined,
|
|
1469
|
-
},
|
|
1470
|
-
};
|
|
1471
|
-
|
|
1472
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
1473
|
-
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1474
2096
|
|
|
1475
|
-
|
|
2097
|
+
describe('GIVEN: Params: estimateLineLabel', () => {
|
|
2098
|
+
describe('WHEN: estimateLineLabel is provided', () => {
|
|
2099
|
+
const $ = cheerio.load(
|
|
2100
|
+
renderComponent('chart', {
|
|
2101
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2102
|
+
estimateLineLabel: 'Estimated value',
|
|
2103
|
+
}),
|
|
2104
|
+
);
|
|
1476
2105
|
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
expect(config.xAxis.endOnTick).toBeUndefined();
|
|
2106
|
+
test('THEN: the estimateLineLabel parameter is ignored', () => {
|
|
2107
|
+
expect($('[data-highcharts-estimate-line-label]').length).toBe(0);
|
|
2108
|
+
});
|
|
1481
2109
|
});
|
|
1482
2110
|
});
|
|
1483
2111
|
|
|
1484
|
-
describe('GIVEN:
|
|
1485
|
-
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
max: 100,
|
|
1493
|
-
startOnTick: false,
|
|
1494
|
-
endOnTick: true,
|
|
1495
|
-
},
|
|
1496
|
-
};
|
|
1497
|
-
|
|
1498
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
1499
|
-
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1500
|
-
|
|
1501
|
-
expect(configScript).toContain('"min":0');
|
|
1502
|
-
expect(configScript).toContain('"max":100');
|
|
1503
|
-
expect(configScript).toContain('"startOnTick":false');
|
|
1504
|
-
expect(configScript).toContain('"endOnTick":true');
|
|
1505
|
-
});
|
|
1506
|
-
|
|
1507
|
-
test('THEN: yAxis min and max are NOT included if not defined', () => {
|
|
1508
|
-
const params = {
|
|
1509
|
-
...BASE_PARAMS,
|
|
1510
|
-
chartType: 'line',
|
|
1511
|
-
yAxis: {
|
|
1512
|
-
...BASE_PARAMS.yAxis,
|
|
1513
|
-
min: undefined,
|
|
1514
|
-
max: undefined,
|
|
1515
|
-
startOnTick: undefined,
|
|
1516
|
-
endOnTick: undefined,
|
|
1517
|
-
},
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
1521
|
-
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
1522
|
-
|
|
1523
|
-
const config = JSON.parse(configScript);
|
|
2112
|
+
describe('GIVEN: Params: uncertaintyRangeLabel', () => {
|
|
2113
|
+
describe('WHEN: uncertaintyRangeLabel is provided', () => {
|
|
2114
|
+
const $ = cheerio.load(
|
|
2115
|
+
renderComponent('chart', {
|
|
2116
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2117
|
+
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
2118
|
+
}),
|
|
2119
|
+
);
|
|
1524
2120
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
expect(config.yAxis.endOnTick).toBeUndefined();
|
|
2121
|
+
test('THEN: the uncertaintyRangeLabel parameter is ignored', () => {
|
|
2122
|
+
expect($('[data-highcharts-uncertainty-range-label]').length).toBe(0);
|
|
2123
|
+
});
|
|
1529
2124
|
});
|
|
1530
2125
|
});
|
|
1531
2126
|
|
|
1532
|
-
describe('GIVEN:
|
|
1533
|
-
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
max: 10,
|
|
1541
|
-
startOnTick: true,
|
|
1542
|
-
endOnTick: true,
|
|
1543
|
-
},
|
|
1544
|
-
};
|
|
1545
|
-
|
|
1546
|
-
const $ = cheerio.load(renderComponent('chart', params));
|
|
1547
|
-
const configScript = $(`script[data-highcharts-config--${params.id}]`).html();
|
|
2127
|
+
describe('GIVEN: Params: customReferenceLineValue', () => {
|
|
2128
|
+
describe('WHEN: customReferenceLineValue is provided', () => {
|
|
2129
|
+
const $ = cheerio.load(
|
|
2130
|
+
renderComponent('chart', {
|
|
2131
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2132
|
+
yAxis: { customReferenceLineValue: 10 },
|
|
2133
|
+
}),
|
|
2134
|
+
);
|
|
1548
2135
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
expect(configScript).not.toContain('"endOnTick":true');
|
|
2136
|
+
test('THEN: the customReferenceLineValue parameter is ignored', () => {
|
|
2137
|
+
expect($('[data-highcharts-custom-reference-line-value]').length).toBe(0);
|
|
2138
|
+
});
|
|
1553
2139
|
});
|
|
1554
2140
|
});
|
|
1555
|
-
});
|
|
1556
2141
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
expect($('.ons-chart__iframe-wrapper').length).toBe(1);
|
|
1569
|
-
});
|
|
1570
|
-
|
|
1571
|
-
test('THEN: it includes the iframe title as a data attribute', () => {
|
|
1572
|
-
const iframe = $('.ons-chart__iframe-wrapper');
|
|
1573
|
-
expect(iframe.attr('data-title')).toBe(EXAMPLE_IFRAME_CHART_PARAMS.title);
|
|
1574
|
-
});
|
|
1575
|
-
|
|
1576
|
-
test('THEN: the theme parameter is ignored', () => {
|
|
1577
|
-
const $ = cheerio.load(
|
|
1578
|
-
renderComponent('chart', {
|
|
1579
|
-
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1580
|
-
theme: 'secondary',
|
|
1581
|
-
}),
|
|
1582
|
-
);
|
|
1583
|
-
|
|
1584
|
-
expect($('[data-highcharts-theme]').length).toBe(0);
|
|
1585
|
-
});
|
|
1586
|
-
|
|
1587
|
-
test('THEN: the percentageHeightDesktop and percentageHeightMobile parameters are ignored', () => {
|
|
1588
|
-
const $ = cheerio.load(
|
|
1589
|
-
renderComponent('chart', {
|
|
1590
|
-
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1591
|
-
percentageHeightDesktop: 50,
|
|
1592
|
-
percentageHeightMobile: 10,
|
|
1593
|
-
}),
|
|
1594
|
-
);
|
|
2142
|
+
describe('GIVEN: Params: chartType', () => {
|
|
2143
|
+
describe('WHEN: chartType is boxplot and legend params are provided', () => {
|
|
2144
|
+
const $ = cheerio.load(
|
|
2145
|
+
renderComponent('chart', {
|
|
2146
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2147
|
+
chartType: 'boxplot',
|
|
2148
|
+
legend: true,
|
|
2149
|
+
estimateLineLabel: 'Estimated value',
|
|
2150
|
+
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
2151
|
+
}),
|
|
2152
|
+
);
|
|
1595
2153
|
|
|
1596
|
-
|
|
1597
|
-
expect($('
|
|
2154
|
+
test('THEN: the boxplot legend is not rendered', () => {
|
|
2155
|
+
expect($('.ons-chart__boxplot-legend').length).toBe(0);
|
|
1598
2156
|
});
|
|
2157
|
+
});
|
|
2158
|
+
});
|
|
1599
2159
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
yAxis: {
|
|
1609
|
-
tickIntervalDesktop: 10,
|
|
1610
|
-
tickIntervalMobile: 5,
|
|
1611
|
-
},
|
|
1612
|
-
}),
|
|
1613
|
-
);
|
|
2160
|
+
describe('GIVEN: Params: invalidChartType', () => {
|
|
2161
|
+
describe('WHEN: an invalid chart type is provided', () => {
|
|
2162
|
+
const $ = cheerio.load(
|
|
2163
|
+
renderComponent('chart', {
|
|
2164
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2165
|
+
chartType: 'foobar',
|
|
2166
|
+
}),
|
|
2167
|
+
);
|
|
1614
2168
|
|
|
1615
|
-
|
|
1616
|
-
expect($('[data-
|
|
1617
|
-
expect($('[data-highcharts-y-axis-tick-interval-desktop]').length).toBe(0);
|
|
1618
|
-
expect($('[data-highcharts-y-axis-tick-interval-mobile]').length).toBe(0);
|
|
2169
|
+
test('THEN: the invalid chart type is ignored', () => {
|
|
2170
|
+
expect($('[data-invalid-chart-type]').length).toBe(0);
|
|
1619
2171
|
});
|
|
2172
|
+
});
|
|
2173
|
+
});
|
|
1620
2174
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
}
|
|
1628
|
-
|
|
2175
|
+
describe('GIVEN: Params: annotations', () => {
|
|
2176
|
+
describe('WHEN: annotations, rangeAnnotations and referenceLineAnnotations are provided', () => {
|
|
2177
|
+
const $ = cheerio.load(
|
|
2178
|
+
renderComponent('chart', {
|
|
2179
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2180
|
+
annotations: [{ text: 'A test point annotation', point: { x: 2, y: 3 } }],
|
|
2181
|
+
rangeAnnotations: [{ text: 'Range annotation', range: { axisValue1: 10, axisValue2: 15 }, axis: 'x' }],
|
|
2182
|
+
referenceLineAnnotations: [{ text: 'Reference line', value: 34, axis: 'x' }],
|
|
2183
|
+
}),
|
|
2184
|
+
);
|
|
1629
2185
|
|
|
1630
|
-
|
|
1631
|
-
expect($('[data-
|
|
2186
|
+
test('THEN: annotations footnotes are not rendered', () => {
|
|
2187
|
+
expect($('[data-annotations-footnotes]').length).toBe(0);
|
|
1632
2188
|
});
|
|
1633
2189
|
|
|
1634
|
-
test('THEN:
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
yAxis: {
|
|
1639
|
-
customReferenceLineValue: 10,
|
|
1640
|
-
},
|
|
1641
|
-
}),
|
|
1642
|
-
);
|
|
1643
|
-
|
|
1644
|
-
expect($('[data-highcharts-custom-reference-line-value]').length).toBe(0);
|
|
2190
|
+
test('THEN: annotation scripts are not rendered', () => {
|
|
2191
|
+
expect($('[data-highcharts-annotations--iframe-chart-123]').length).toBe(0);
|
|
2192
|
+
expect($('[data-highcharts-range-annotations--iframe-chart-123]').length).toBe(0);
|
|
2193
|
+
expect($('[data-highcharts-reference-line-annotations--iframe-chart-123]').length).toBe(0);
|
|
1645
2194
|
});
|
|
2195
|
+
});
|
|
2196
|
+
});
|
|
1646
2197
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1651
|
-
chartType: 'boxplot',
|
|
1652
|
-
legend: true,
|
|
1653
|
-
estimateLineLabel: 'Estimated value',
|
|
1654
|
-
uncertaintyRangeLabel: '95% Confidence Interval',
|
|
1655
|
-
}),
|
|
1656
|
-
);
|
|
1657
|
-
|
|
1658
|
-
expect($('.ons-chart__boxplot-legend').length).toBe(0);
|
|
1659
|
-
});
|
|
2198
|
+
describe('GIVEN: Params: iframeAspectRatio', () => {
|
|
2199
|
+
describe('WHEN: iframeAspectRatio is not set', () => {
|
|
2200
|
+
const $ = cheerio.load(renderComponent('chart', EXAMPLE_IFRAME_CHART_PARAMS));
|
|
1660
2201
|
|
|
1661
|
-
test('THEN:
|
|
1662
|
-
|
|
1663
|
-
expect(configScript).toBeNull();
|
|
2202
|
+
test('THEN: it defaults to 16-9', () => {
|
|
2203
|
+
expect($('.ons-chart__iframe').hasClass('ons-chart__iframe--16-9')).toBe(true);
|
|
1664
2204
|
});
|
|
2205
|
+
});
|
|
1665
2206
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
point: { x: 2, y: 3 },
|
|
1674
|
-
labelOffsetX: 10,
|
|
1675
|
-
labelOffsetY: -50,
|
|
1676
|
-
},
|
|
1677
|
-
],
|
|
1678
|
-
rangeAnnotations: [
|
|
1679
|
-
{
|
|
1680
|
-
text: 'A test x axis range annotation',
|
|
1681
|
-
range: { axisValue1: 10, axisValue2: 15 },
|
|
1682
|
-
axis: 'x',
|
|
1683
|
-
labelOffsetX: 150,
|
|
1684
|
-
labelOffsetY: 0,
|
|
1685
|
-
},
|
|
1686
|
-
{
|
|
1687
|
-
text: 'A test y axis range annotation with the label inside',
|
|
1688
|
-
range: { axisValue1: 5, axisValue2: 10 },
|
|
1689
|
-
axis: 'y',
|
|
1690
|
-
labelInside: true,
|
|
1691
|
-
labelWidth: 250,
|
|
1692
|
-
},
|
|
1693
|
-
],
|
|
1694
|
-
referenceLineAnnotations: [
|
|
1695
|
-
{
|
|
1696
|
-
text: 'A test x axis reference line annotation',
|
|
1697
|
-
value: 34,
|
|
1698
|
-
axis: 'x',
|
|
1699
|
-
},
|
|
1700
|
-
{
|
|
1701
|
-
text: 'A test y axis reference line annotation',
|
|
1702
|
-
value: 12,
|
|
1703
|
-
axis: 'y',
|
|
1704
|
-
labelWidth: 100,
|
|
1705
|
-
},
|
|
1706
|
-
],
|
|
1707
|
-
}),
|
|
1708
|
-
);
|
|
2207
|
+
describe('WHEN: iframeAspectRatio is unsupported', () => {
|
|
2208
|
+
const $ = cheerio.load(
|
|
2209
|
+
renderComponent('chart', {
|
|
2210
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2211
|
+
iframeAspectRatio: '16-10',
|
|
2212
|
+
}),
|
|
2213
|
+
);
|
|
1709
2214
|
|
|
1710
|
-
|
|
1711
|
-
expect($('
|
|
1712
|
-
expect($('[data-highcharts-range-annotations--iframe-chart-123]').length).toBe(0);
|
|
1713
|
-
expect($('[data-highcharts-reference-line-annotations--iframe-chart-123]').length).toBe(0);
|
|
2215
|
+
test('THEN: it defaults to 16-9', () => {
|
|
2216
|
+
expect($('.ons-chart__iframe').hasClass('ons-chart__iframe--16-9')).toBe(true);
|
|
1714
2217
|
});
|
|
2218
|
+
});
|
|
1715
2219
|
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
)
|
|
2220
|
+
describe('WHEN: iframeAspectRatio is supported', () => {
|
|
2221
|
+
const aspectRatio = '21-9';
|
|
2222
|
+
const $ = cheerio.load(
|
|
2223
|
+
renderComponent('chart', {
|
|
2224
|
+
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
2225
|
+
iframeAspectRatio: aspectRatio,
|
|
2226
|
+
}),
|
|
2227
|
+
);
|
|
1723
2228
|
|
|
1724
|
-
|
|
2229
|
+
test('THEN: it applies the aspect ratio class', () => {
|
|
2230
|
+
expect($('.ons-chart__iframe').hasClass(`ons-chart__iframe--${aspectRatio}`)).toBe(true);
|
|
1725
2231
|
});
|
|
1726
2232
|
});
|
|
2233
|
+
});
|
|
1727
2234
|
|
|
1728
|
-
|
|
2235
|
+
describe('GIVEN: Params: fallbackImageUrl', () => {
|
|
2236
|
+
describe('WHEN: fallbackImageUrl is provided', () => {
|
|
1729
2237
|
const $ = cheerio.load(
|
|
1730
2238
|
renderComponent('chart', {
|
|
1731
2239
|
...EXAMPLE_IFRAME_CHART_PARAMS,
|
|
1732
2240
|
fallbackImageUrl: '/img/small/line-chart-screenshot.png',
|
|
1733
2241
|
}),
|
|
1734
2242
|
);
|
|
1735
|
-
|
|
1736
|
-
test('THEN: the iframe is hidden when JavaScript is disabled', () => {
|
|
1737
|
-
expect(
|
|
2243
|
+
|
|
2244
|
+
test('THEN: the iframe wrapper is hidden when JavaScript is disabled', () => {
|
|
2245
|
+
expect($('.ons-chart__iframe-wrapper').attr('class')).toContain('ons-chart__non-js-hide');
|
|
1738
2246
|
});
|
|
1739
2247
|
});
|
|
1740
2248
|
});
|