Skip to content

Commit b831cc8

Browse files
committed
tests: add test for 'Heatmap with Categorical Axis Labels' example
1 parent 92234b7 commit b831cc8

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

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

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ describe('scientific charts, part 2', () => {
1818
{
1919
"z": [ [ 1, 20, 30 ],
2020
[ 20, 1, 60 ],
21-
[ 30, 60, 1 ]
22-
],
21+
[ 30, 60, 1 ] ],
2322
"type": "heatmap"
2423
}
2524
],
@@ -45,7 +44,55 @@ describe('scientific charts, part 2', () => {
4544
});
4645
});
4746

48-
// TODO: Heatmap with Categorical Axis Labels - https://plotly.com/javascript/heatmaps/#heatmap-with-categorical-axis-labels
47+
it('Heatmap with Categorical Axis Labels', () => {
48+
const options = {
49+
port: 3000,
50+
host: 'localhost',
51+
method: 'POST'
52+
};
53+
54+
const req = http.request(options);
55+
// Data taken from https://plotly.com/javascript/heatmaps/#heatmap-with-categorical-axis-labels example.
56+
const payload = `{
57+
"data": [
58+
{
59+
"z": [ [ 1, null, 30, 50, 1 ],
60+
[ 20, 1, 60, 80, 30 ],
61+
[ 30, 60, 1, -10, 20 ] ],
62+
"x": [
63+
"Monday",
64+
"Tuesday",
65+
"Wednesday",
66+
"Thursday",
67+
"Friday"
68+
],
69+
"y": [ "Morning", "Afternoon", "Evening" ],
70+
"type": "heatmap",
71+
"hoverongaps": false
72+
}
73+
],
74+
"layout": {}
75+
}`;
76+
req.write(payload);
77+
req.end();
78+
79+
req.on('response', (response) => {
80+
assert.strictEqual(500, response.statusCode);
81+
let body = '';
82+
response.on('data', (chunk) => {
83+
body += chunk;
84+
});
85+
response.on('end', () => {
86+
// Browser-based answer is an SVG with embedded binary PNG image data
87+
// (due to heatmap colouring).
88+
89+
// Currently, the server cannot handle that and returns HTTP status code 500.
90+
// Reasons seem to be the heatmap colouring and the labels.
91+
assert.ok(body == '{"success":false,"failure":"promise-rejected"}');
92+
});
93+
});
94+
});
95+
4996
// TODO: Annotated Heatmap - https://plotly.com/javascript/heatmaps/#annotated-heatmap
5097
// TODO: Heatmap with Unequal Block Sizes - https://plotly.com/javascript/heatmaps/#heatmap-with-unequal-block-sizes
5198

0 commit comments

Comments
 (0)