@@ -82,6 +82,9 @@ suite("RowViewModelFactory.buildSeparator() tests", () => {
8282 const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
8383 const table = threeColumnTable ( ) ;
8484
85+ _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "" ) ;
86+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "" ) ;
87+
8588 const separatorRowViewModel = sut . buildSeparator ( table ) ;
8689
8790 _separatorPadCalculator . verify ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , 0 ) , Times . once ( ) ) ;
@@ -96,6 +99,8 @@ suite("RowViewModelFactory.buildSeparator() tests", () => {
9699 test ( "Value returned from padCalculator.getLeftPadding is used to start the row value" , ( ) => {
97100 const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
98101 const table = threeColumnTable ( ) ;
102+
103+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "" ) ;
99104 _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , 0 ) ) . returns ( ( ) => "test" ) ;
100105
101106 const separatorRowViewModel = sut . buildSeparator ( table ) ;
@@ -125,24 +130,76 @@ suite("RowViewModelFactory.buildSeparator() tests", () => {
125130 assertExt . isNotNull ( separatorRowViewModel ) ;
126131 assert . equal ( separatorRowViewModel . getValueAt ( 1 ) , "LeftRight" ) ;
127132 } ) ;
133+
134+ test ( "Not set alignment column separator does not contain :" , ( ) => {
135+ const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
136+ const table = threeColumnTable ( Alignment . NotSet ) ;
137+
138+ _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
139+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
140+
141+ const separatorRowViewModel = sut . buildSeparator ( table ) ;
142+
143+ for ( let col = 0 ; col < separatorRowViewModel . columnCount ; col ++ )
144+ assert . equal ( separatorRowViewModel . getValueAt ( col ) , "----" ) ;
145+ } ) ;
146+
147+ test ( "Left aligned column separator starts with :" , ( ) => {
148+ const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
149+ const table = threeColumnTable ( Alignment . Left ) ;
150+
151+ _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
152+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
153+
154+ const separatorRowViewModel = sut . buildSeparator ( table ) ;
155+
156+ for ( let col = 0 ; col < separatorRowViewModel . columnCount ; col ++ )
157+ assert . equal ( separatorRowViewModel . getValueAt ( col ) , ":---" ) ;
158+ } ) ;
159+
160+ test ( "Right aligned column separator ends with :" , ( ) => {
161+ const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
162+ const table = threeColumnTable ( Alignment . Right ) ;
163+
164+ _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
165+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
166+
167+ const separatorRowViewModel = sut . buildSeparator ( table ) ;
168+
169+ for ( let col = 0 ; col < separatorRowViewModel . columnCount ; col ++ )
170+ assert . equal ( separatorRowViewModel . getValueAt ( col ) , "---:" ) ;
171+ } ) ;
172+
173+ test ( "Centrally aligned column separator starts and ends with :" , ( ) => {
174+ const sut = createFactory ( _contentPadCalculator . object , _separatorPadCalculator . object ) ;
175+ const table = threeColumnTable ( Alignment . Center ) ;
176+
177+ _separatorPadCalculator . setup ( _ => _ . getLeftPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
178+ _separatorPadCalculator . setup ( _ => _ . getRightPadding ( It . isAny ( ) , It . isAny ( ) , It . isAny ( ) ) ) . returns ( ( ) => "--" ) ;
179+
180+ const separatorRowViewModel = sut . buildSeparator ( table ) ;
181+
182+ for ( let col = 0 ; col < separatorRowViewModel . columnCount ; col ++ )
183+ assert . equal ( separatorRowViewModel . getValueAt ( col ) , ":--:" ) ;
184+ } ) ;
128185} ) ;
129186
130- function threeColumnTable ( ) : Table {
187+ function threeColumnTable ( alignment : Alignment = Alignment . NotSet ) : Table {
131188 return tableFor ( [
132189 [ "aaaaa" , "bbbbb" , "ccccc" ] ,
133190 [ "aaaaa" , "bbbbb" , "ccccc" ]
134- ] ) ;
191+ ] , alignment ) ;
135192}
136193
137- function threeColumnTableWithEmptyMiddleColumn ( ) : Table {
194+ function threeColumnTableWithEmptyMiddleColumn ( alignment : Alignment = Alignment . NotSet ) : Table {
138195 return tableFor ( [
139196 [ "aaaaa" , "" , "ccccc" ] ,
140197 [ "aaaaa" , "" , "ccccc" ]
141- ] ) ;
198+ ] , alignment ) ;
142199}
143200
144- function tableFor ( rows : string [ ] [ ] ) {
145- const alignments : Alignment [ ] = rows [ 0 ] . map ( r => Alignment . Left ) ;
201+ function tableFor ( rows : string [ ] [ ] , alignment : Alignment ) {
202+ const alignments : Alignment [ ] = rows [ 0 ] . map ( r => alignment ) ;
146203 let table = new Table ( rows . map ( row => row . map ( c => new Cell ( c ) ) ) , alignments ) ;
147204 return table ;
148205}
0 commit comments