@@ -6,7 +6,8 @@ import { RowViewModelFactory } from '../../../src/viewModelFactories/rowViewMode
66import { Table } from '../../../src/models/table' ;
77import { Alignment } from '../../../src/models/alignment' ;
88import { Cell } from '../../../src/models/cell' ;
9- import { AlignmentMarkerStrategy , IAlignmentMarker } from '../../../src/viewModelFactories/alignmentMarking' ;
9+ import { AlignmentMarkerStrategy , IAlignmentMarker , NotSetAlignmentMarker } from '../../../src/viewModelFactories/alignmentMarking' ;
10+ import { RowViewModel } from '../../../src/viewModels/rowViewModel' ;
1011
1112suite ( "RowViewModelFactory.buildRow() tests" , ( ) => {
1213 let _contentPadCalculator : IMock < PadCalculator > ;
@@ -70,19 +71,42 @@ suite("RowViewModelFactory.buildRow() tests", () => {
7071
7172suite ( "RowViewModelFactory.buildSeparator() tests" , ( ) => {
7273 let _contentPadCalculator : IMock < PadCalculator > ;
73- let _separatorPadCalculator : IMock < PadCalculator > ;
7474
7575 setup ( ( ) => {
7676 _contentPadCalculator = Mock . ofType < PadCalculator > ( ) ;
77- _separatorPadCalculator = Mock . ofType < PadCalculator > ( ) ;
7877 } ) ;
7978
80- test ( "Fills the max length with -" , ( ) => {
81- assert . equal ( 0 , 1 , "TODO" ) ;
79+ test ( "Fills separator with dashes using the max length of the columns" , ( ) => {
80+ const sut = createFactory ( _contentPadCalculator . object ) ;
81+ const table = threeColumnTable ( ) ;
82+ const rows : RowViewModel [ ] = [
83+ new RowViewModel ( [ "abc" , "defghi" ] ) ,
84+ new RowViewModel ( [ "abcd" , "efgh" ] )
85+ ] ;
86+
87+ const separator = sut . buildSeparator ( rows , table ) ;
88+
89+ assert . equal ( separator . getValueAt ( 0 ) , "----" ) ;
90+ assert . equal ( separator . getValueAt ( 1 ) , "------" ) ;
8291 } ) ;
8392
8493 test ( "Calls marker to mark the beginning and end" , ( ) => {
85- assert . equal ( 0 , 1 , "TODO" ) ;
94+ const alignmentStrategy = Mock . ofType < AlignmentMarkerStrategy > ( ) ;
95+ const alignmentMarker = Mock . ofType < IAlignmentMarker > ( ) ;
96+ alignmentMarker . setup ( _ => _ . mark ( It . isAny ( ) ) ) . returns ( ( input ) => input ) . verifiable ( Times . exactly ( 3 ) ) ;
97+ alignmentStrategy . setup ( _ => _ . markerFor ( It . isAny ( ) ) ) . returns ( ( ) => alignmentMarker . object ) . verifiable ( Times . exactly ( 3 ) ) ;
98+
99+ const sut = createFactory ( _contentPadCalculator . object , alignmentStrategy . object ) ;
100+ const table = threeColumnTable ( ) ;
101+ const rows : RowViewModel [ ] = [
102+ new RowViewModel ( [ "abc" , "defghi" , "xyx" ] ) ,
103+ new RowViewModel ( [ "abcd" , "efgh" , "xyz" ] )
104+ ] ;
105+
106+ const separator = sut . buildSeparator ( rows , table ) ;
107+
108+ alignmentStrategy . verifyAll ( ) ;
109+ alignmentMarker . verifyAll ( ) ;
86110 } ) ;
87111} ) ;
88112
0 commit comments