1
1
describe ( 'Cell' , function ( ) {
2
- const colors = require ( 'colors ' ) ;
2
+ const chalk = require ( 'chalk ' ) ;
3
3
const Cell = require ( '../src/cell' ) ;
4
4
const { ColSpanCell, RowSpanCell } = Cell ;
5
5
const { mergeOptions } = require ( '../src/utils' ) ;
6
6
7
+ chalk . level = 3 ;
8
+
7
9
function defaultOptions ( ) {
8
10
//overwrite coloring of head and border by default for easier testing.
9
11
return mergeOptions ( { style : { head : [ ] , border : [ ] } } ) ;
@@ -603,7 +605,7 @@ describe('Cell', function () {
603
605
604
606
it ( 'will draw in the color specified by border style' , function ( ) {
605
607
cell . border = [ 'gray' ] ;
606
- expect ( cell . draw ( 'top' ) ) . toEqual ( colors . gray ( '┌───────' ) ) ;
608
+ expect ( cell . draw ( 'top' ) ) . toEqual ( chalk . gray ( '┌───────' ) ) ;
607
609
} ) ;
608
610
} ) ;
609
611
@@ -626,7 +628,7 @@ describe('Cell', function () {
626
628
627
629
it ( 'will draw in the color specified by border style' , function ( ) {
628
630
cell . border = [ 'gray' ] ;
629
- expect ( cell . draw ( 'bottom' ) ) . toEqual ( colors . gray ( '└───────' ) ) ;
631
+ expect ( cell . draw ( 'bottom' ) ) . toEqual ( chalk . gray ( '└───────' ) ) ;
630
632
} ) ;
631
633
} ) ;
632
634
@@ -639,8 +641,8 @@ describe('Cell', function () {
639
641
it ( 'draws an empty line' , function ( ) {
640
642
cell . border = [ 'gray' ] ;
641
643
cell . head = [ 'red' ] ;
642
- expect ( cell . drawEmpty ( ) ) . toEqual ( colors . gray ( 'L' ) + colors . red ( ' ' ) ) ;
643
- expect ( cell . drawEmpty ( true ) ) . toEqual ( colors . gray ( 'L' ) + colors . red ( ' ' ) + colors . gray ( 'R' ) ) ;
644
+ expect ( cell . drawEmpty ( ) ) . toEqual ( chalk . gray ( 'L' ) + chalk . red ( ' ' ) ) ;
645
+ expect ( cell . drawEmpty ( true ) ) . toEqual ( chalk . gray ( 'L' ) + chalk . red ( ' ' ) + chalk . gray ( 'R' ) ) ;
644
646
} ) ;
645
647
} ) ;
646
648
@@ -682,17 +684,17 @@ describe('Cell', function () {
682
684
it ( 'left and right will be drawn in color of border style' , function ( ) {
683
685
cell . border = [ 'gray' ] ;
684
686
cell . x = 0 ;
685
- expect ( cell . draw ( 0 ) ) . toEqual ( colors . gray ( 'L' ) + ' hello ' ) ;
687
+ expect ( cell . draw ( 0 ) ) . toEqual ( chalk . gray ( 'L' ) + ' hello ' ) ;
686
688
cell . drawRight = true ;
687
- expect ( cell . draw ( 0 ) ) . toEqual ( colors . gray ( 'L' ) + ' hello ' + colors . gray ( 'R' ) ) ;
689
+ expect ( cell . draw ( 0 ) ) . toEqual ( chalk . gray ( 'L' ) + ' hello ' + chalk . gray ( 'R' ) ) ;
688
690
} ) ;
689
691
690
692
it ( 'text will be drawn in color of head style if y == 0' , function ( ) {
691
693
cell . head = [ 'red' ] ;
692
694
cell . x = cell . y = 0 ;
693
- expect ( cell . draw ( 0 ) ) . toEqual ( 'L' + colors . red ( ' hello ' ) ) ;
695
+ expect ( cell . draw ( 0 ) ) . toEqual ( 'L' + chalk . red ( ' hello ' ) ) ;
694
696
cell . drawRight = true ;
695
- expect ( cell . draw ( 0 ) ) . toEqual ( 'L' + colors . red ( ' hello ' ) + 'R' ) ;
697
+ expect ( cell . draw ( 0 ) ) . toEqual ( 'L' + chalk . red ( ' hello ' ) + 'R' ) ;
696
698
} ) ;
697
699
698
700
it ( 'text will NOT be drawn in color of head style if y == 1' , function ( ) {
@@ -707,9 +709,9 @@ describe('Cell', function () {
707
709
cell . border = [ 'gray' ] ;
708
710
cell . head = [ 'red' ] ;
709
711
cell . x = cell . y = 0 ;
710
- expect ( cell . draw ( 0 ) ) . toEqual ( colors . gray ( 'L' ) + colors . red ( ' hello ' ) ) ;
712
+ expect ( cell . draw ( 0 ) ) . toEqual ( chalk . gray ( 'L' ) + chalk . red ( ' hello ' ) ) ;
711
713
cell . drawRight = true ;
712
- expect ( cell . draw ( 0 ) ) . toEqual ( colors . gray ( 'L' ) + colors . red ( ' hello ' ) + colors . gray ( 'R' ) ) ;
714
+ expect ( cell . draw ( 0 ) ) . toEqual ( chalk . gray ( 'L' ) + chalk . red ( ' hello ' ) + chalk . gray ( 'R' ) ) ;
713
715
} ) ;
714
716
} ) ;
715
717
0 commit comments