Skip to content

Commit 359ae19

Browse files
committed
Add tests for supported chart types
1 parent aecefd4 commit 359ae19

File tree

1 file changed

+69
-2
lines changed
  • lib/node_modules/@stdlib/plot/sparklines/unicode/test

1 file changed

+69
-2
lines changed

lib/node_modules/@stdlib/plot/sparklines/unicode/test/test.main.js

+69-2
Original file line numberDiff line numberDiff line change
@@ -440,17 +440,84 @@ tape( 'an instance has a `render` method for rendering a chart', function test(
440440
str = chart.render();
441441
t.strictEqual( str, '▁█▅▃▆▆▅', 'returns rendered chart' );
442442

443-
chart.type = 'column';
443+
t.end();
444+
});
445+
446+
tape( 'an instance supports rendering a column chart', function test( t ) {
447+
var chart;
448+
var str;
449+
450+
chart = new UnicodeSparkline({
451+
'type': 'column'
452+
});
453+
chart.data = [ 1.0, 5.0, 3.0, 2.0, 4.0, 4.0, 3.0 ];
454+
444455
str = chart.render();
445456
t.strictEqual( str, '▁█▅▃▆▆▅', 'returns rendered chart' );
446457

447-
chart.type = 'line';
458+
t.end();
459+
});
460+
461+
tape( 'an instance supports rendering a line chart', function test( t ) {
462+
var chart;
463+
var str;
464+
465+
chart = new UnicodeSparkline({
466+
'type': 'line'
467+
});
468+
chart.data = [ 1.0, 5.0, 3.0, 2.0, 4.0, 4.0, 3.0 ];
469+
448470
str = chart.render();
449471
t.strictEqual( str, '⡈⠑⠢⠔⠒⠒⠒', 'returns rendered chart' );
450472

451473
t.end();
452474
});
453475

476+
tape( 'an instance supports rendering a tristate chart', function test( t ) {
477+
var chart;
478+
var str;
479+
480+
chart = new UnicodeSparkline({
481+
'type': 'tristate'
482+
});
483+
chart.data = [ -1, 1, 0, 0, 1, -1, -1, 1 ];
484+
485+
str = chart.render();
486+
t.strictEqual( str, '▄▀──▀▄▄▀', 'returns rendered chart' );
487+
488+
t.end();
489+
});
490+
491+
tape( 'an instance supports rendering an up/down chart', function test( t ) {
492+
var chart;
493+
var str;
494+
495+
chart = new UnicodeSparkline({
496+
'type': 'up-down'
497+
});
498+
chart.data = [ -1, 1, 1, 1, 1, -1, -1, 1 ];
499+
500+
str = chart.render();
501+
t.strictEqual( str, '↓↑↑↑↑↓↓↑', 'returns rendered chart' );
502+
503+
t.end();
504+
});
505+
506+
tape( 'an instance supports rendering a win/loss chart', function test( t ) {
507+
var chart;
508+
var str;
509+
510+
chart = new UnicodeSparkline({
511+
'type': 'win-loss'
512+
});
513+
chart.data = [ -2, 1, 2, 2, 1, -1, -1, 1, -2, -2, 2, 2, -2 ];
514+
515+
str = chart.render();
516+
t.strictEqual( str, '┌╵└┴╵╷╷╵┌┬┴┴┬', 'returns rendered chart' );
517+
518+
t.end();
519+
});
520+
454521
tape( 'if a chart has not been provided data, the render method returns an empty string', function test( t ) {
455522
var chart;
456523
var str;

0 commit comments

Comments
 (0)