@@ -440,17 +440,84 @@ tape( 'an instance has a `render` method for rendering a chart', function test(
440
440
str = chart . render ( ) ;
441
441
t . strictEqual ( str , '▁█▅▃▆▆▅' , 'returns rendered chart' ) ;
442
442
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
+
444
455
str = chart . render ( ) ;
445
456
t . strictEqual ( str , '▁█▅▃▆▆▅' , 'returns rendered chart' ) ;
446
457
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
+
448
470
str = chart . render ( ) ;
449
471
t . strictEqual ( str , '⡈⠑⠢⠔⠒⠒⠒' , 'returns rendered chart' ) ;
450
472
451
473
t . end ( ) ;
452
474
} ) ;
453
475
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
+
454
521
tape ( 'if a chart has not been provided data, the render method returns an empty string' , function test ( t ) {
455
522
var chart ;
456
523
var str ;
0 commit comments