Skip to content

Commit e9d6fa2

Browse files
committed
tests: add test for 'Heatmap with Unequal Block Sizes' example
1 parent d4893ea commit e9d6fa2

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

export-server/tests/charts/scientific/heatmap.test.js

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,160 @@ describe('scientific charts, part 2', () => {
376376
});
377377

378378
// TODO: Heatmap with Unequal Block Sizes - https://plotly.com/javascript/heatmaps/#heatmap-with-unequal-block-sizes
379+
it('Heatmap with Unequal Block Sizes', () => {
380+
const options = {
381+
port: 3000,
382+
host: 'localhost',
383+
method: 'POST'
384+
};
385+
386+
const req = http.request(options);
387+
// Data taken from https://plotly.com/javascript/heatmaps/#heatmap-with-unequal-block-sizes example.
388+
// The amount of steps has been reduced from 1000 to 100 to shrink the rather huge JSON to a more
389+
// manageable size.
390+
const payload = `{
391+
"data": [
392+
{
393+
"x": [
394+
0, 0.019128908461409244, 0.057053985548463304, 0.11167630648236293,
395+
0.1807634484246753, 0.2619988983495748, 0.35302917356026364,
396+
0.45150800102827526, 0.5551370032507141, 0.6617024418072166,
397+
0.7691076732866533, 0.8754010739243909, 0.9787992874959733,
398+
1.0777057442905533, 1.1707244860734565, 1.2566694117832458,
399+
1.3345691304439335, 1.4036676707641937, 1.463421350701835,
400+
1.5134921546477325, 1.5537380007676371, 1.5842003065430512,
401+
1.6050892769403848, 1.616767347317515, 1.6197312126772536,
402+
1.6145928668302587, 1.6020600601521502, 1.5829165636930556,
403+
1.5580026012512502, 1.5281957805132902, 1.4943928203597332,
404+
1.4574923348020647, 1.4183788955970724, 1.3779085561909294,
405+
1.3368959800433016, 1.2961032772836907, 1.2562306157067487,
406+
1.2179086358994669, 1.1816926663154543, 1.1480587027967175,
407+
1.1174010887388532, 1.0900318070694117, 1.0661812736513727,
408+
1.0460005037487647, 1.029564508842323, 1.0168767703355692,
409+
1.0078746294602619, 1.0024354288339163, 1.0003832404516118,
410+
1.0014960171785756, 1.005513009783773, 1.0121422989255258,
411+
1.0210683009558572, 1.0319591176257341, 1.0444736124174285,
412+
1.0582681099717781, 1.073002629592033, 1.0883465787783007,
413+
1.103983847879284, 1.1196172619628488, 1.134972360649084,
414+
1.1498004906899766, 1.1638812093177253, 1.1770240086475543,
415+
1.1890693825693663, 1.1998892674847643, 1.2093868968609132,
416+
1.217496116828681, 1.2241802159254633, 1.2294303265752906,
417+
1.233263459036496, 1.2357202303784562, 1.2368623516410997,
418+
1.236769935768015, 1.2355386872840055, 1.2332770321198443,
419+
1.230103242588197, 1.2261426084082023, 1.2215246999881662,
420+
1.216380765032925, 1.2108412940697177, 1.2050337848051997,
421+
1.199080729452264, 1.19309784340715, 1.1871925480149113,
422+
1.1814627147250412, 1.1759956727887142, 1.1708674778534665,
423+
1.1661424344274085, 1.1618728612589475, 1.1580990852435622,
424+
1.1548496465493678, 1.1521416952600834, 1.1499815579695218,
425+
1.1483654514183217, 1.1472803194252574, 1.1467047690083163,
426+
1.14661008168445, 1.146961276445466, 1.14771820179039
427+
],
428+
"y": [
429+
0.2932495072029474, 0.4520649106465986, 0.6010613308541781,
430+
0.738368460180875, 0.8624639584341823, 0.9721736901564527,
431+
1.0666658241955516, 1.1454393669989154, 1.2083077553451718,
432+
1.2553781733731144, 1.2870272832454868, 1.303874069282395,
433+
1.3067504927970526, 1.2966706402090562, 1.2747990214737537,
434+
1.2424186407283688, 1.2008994176656302, 1.1516674878951316,
435+
1.0961758548475138, 1.035876806011451, 0.9721964438281766,
436+
0.9065116177063758, 0.840129479590633, 0.7742698224571861,
437+
0.7100503000559907, 0.6484745680881383, 0.5904233326013655,
438+
0.5366482413760394, 0.4877685090036233, 0.4442701266447717,
439+
0.4065074733848051, 0.3747071178488449, 0.3489735763509304,
440+
0.32929677727725376, 0.31556097049152865, 0.30755481506069376,
441+
0.304982378214948, 0.30747478279516444, 0.31460224906683987,
442+
0.325886289214605, 0.340811828566144, 0.35883904610114165,
443+
0.379414747543091, 0.4019831067745736, 0.4259956349359092,
444+
0.4509202608581578, 0.47624943096616845, 0.5015071610207071,
445+
0.5262549956438493, 0.5500968541246922, 0.5726827622145094,
446+
0.5937114892211545, 0.6129321274801305, 0.6301446670417022,
447+
0.6451996320455782, 0.6579968566797538, 0.6684834878054817,
448+
0.6766513082852681, 0.6825334798230427, 0.686200806797658,
449+
0.6877576232557542, 0.6873374040671552, 0.6850981983966132,
450+
0.6812179792884621, 0.675889997487091, 0.6693182208261246,
451+
0.6617129328172129, 0.653286555660238, 0.6442497539822349,
452+
0.6348078663875566, 0.6251577025525819, 0.6154847342983527,
453+
0.6059606999836173, 0.5967416328227023, 0.5879663154741106,
454+
0.5797551555753451, 0.5722094699071738, 0.5654111586275965,
455+
0.5594227455747569, 0.5542877560334796, 0.5500313996091797,
456+
0.546661522956461, 0.5441697950535818, 0.5425330864702043,
457+
0.5417150036044319, 0.541667539115482, 0.5423328006910482,
458+
0.5436447817969594, 0.5455311400892174, 0.5479149516492453,
459+
0.5507164120544509, 0.5538544584396448, 0.557248290062953,
460+
0.5608187683872439, 0.5644896812526723, 0.568188859279963,
461+
0.5718491361449152, 0.5754091477455934, 0.5788139684944997,
462+
0.5820155859652323
463+
],
464+
"type": "scatter",
465+
"line": {
466+
"color": "white",
467+
"width": 3
468+
}
469+
},
470+
{
471+
"x": [ 0, 1, 1.1458980337503155, 1.2360679774997898, 1.618033988749895 ],
472+
"y": [ 0.2932495072029474, 0.5293174847027371, 0.6752155184530526, 0.6752155184530526, 1.2932495072029475 ],
473+
"z": [ [ 13, 3, 3, 5 ],
474+
[ 13, 2, 1, 5 ],
475+
[ 13, 10, 11, 12 ],
476+
[ 13, 8, 8, 8 ] ],
477+
"type": "heatmap",
478+
"colorscale": "Viridis"
479+
}
480+
],
481+
"layout": {
482+
"title": {
483+
"text": "Heatmap with Unequal Block Sizes"
484+
},
485+
"margin": {
486+
"t": 200,
487+
"r": 200,
488+
"b": 200,
489+
"l": 200
490+
},
491+
"xaxis": {
492+
"range": [ 0, 1.6 ],
493+
"autorange": false,
494+
"showgrid": false,
495+
"zeroline": false,
496+
"linecolor": "black",
497+
"showticklabels": false,
498+
"ticks": ""
499+
},
500+
"yaxis": {
501+
"range": [ 0, 1.6 ],
502+
"autorange": false,
503+
"showgrid": false,
504+
"zeroline": false,
505+
"linecolor": "black",
506+
"showticklabels": false,
507+
"ticks": ""
508+
},
509+
"showlegend": false,
510+
"width": 700,
511+
"height": 700,
512+
"autosize": false
513+
}
514+
}`;
515+
req.write(payload);
516+
req.end();
517+
518+
req.on('response', (response) => {
519+
assert.strictEqual(500, response.statusCode);
520+
let body = '';
521+
response.on('data', (chunk) => {
522+
body += chunk;
523+
});
524+
response.on('end', () => {
525+
// Browser-based answer is an SVG with embedded binary PNG image data
526+
// (due to heatmap colouring).
527+
528+
// Currently, the server cannot handle that and returns HTTP status code 500.
529+
assert.ok(body == '{"success":false,"failure":"promise-rejected"}');
530+
});
531+
});
532+
});
379533

380534
/*
381535
it('request with different data', () => {

0 commit comments

Comments
 (0)