1- import { MAX_COLUMN_WIDTH , getColumnWidth } from './getColumnWidth' ;
1+ import {
2+ MAX_COLUMN_WIDTH ,
3+ PADDING_NO_SORT_ICON ,
4+ PADDING_WITH_SORT_ICON ,
5+ getColumnWidth ,
6+ } from './getColumnWidth' ;
27
38describe ( 'getColumnWidth' , ( ) => {
49 it ( 'returns minimum width for empty data' , ( ) => {
510 const result = getColumnWidth ( { data : [ ] , name : 'test' , columnType : 'string' } ) ;
6- expect ( result ) . toBe ( 20 + 'test' . length * 10 ) ;
11+ expect ( result ) . toBe ( PADDING_NO_SORT_ICON + 'test' . length * 10 ) ;
712 } ) ;
813
914 it ( 'calculates correct width for string columns' , ( ) => {
1015 const data = [ { test : 'short' } , { test : 'medium length' } , { test : 'this is a longer string' } ] ;
1116 const result = getColumnWidth ( { data, name : 'test' , columnType : 'string' } ) ;
12- expect ( result ) . toBe ( 20 + 'this is a longer string' . length * 10 ) ;
17+ expect ( result ) . toBe ( PADDING_NO_SORT_ICON + 'this is a longer string' . length * 10 ) ;
1318 } ) ;
1419
1520 it ( 'calculates correct width for number columns' , ( ) => {
1621 const data = [ { test : 123 } , { test : 456789 } , { test : 0 } ] ;
1722 const result = getColumnWidth ( { data, name : 'test' , columnType : 'number' } ) ;
18- expect ( result ) . toBe ( 40 + '456789' . length * 10 ) ;
23+ expect ( result ) . toBe ( PADDING_WITH_SORT_ICON + '456789' . length * 10 ) ;
1924 } ) ;
2025
2126 it ( 'returns MAX_COLUMN_WIDTH when calculated width exceeds it' , ( ) => {
@@ -26,18 +31,18 @@ describe('getColumnWidth', () => {
2631
2732 it ( 'handles undefined data correctly' , ( ) => {
2833 const result = getColumnWidth ( { name : 'test' , columnType : 'string' } ) ;
29- expect ( result ) . toBe ( 20 + 'test' . length * 10 ) ;
34+ expect ( result ) . toBe ( PADDING_NO_SORT_ICON + 'test' . length * 10 ) ;
3035 } ) ;
3136
3237 it ( 'handles missing values in data correctly' , ( ) => {
3338 const data = [ { test : 'short' } , { } , { test : 'longer string' } ] ;
3439 const result = getColumnWidth ( { data, name : 'test' , columnType : 'string' } ) ;
35- expect ( result ) . toBe ( 20 + 'longer string' . length * 10 ) ;
40+ expect ( result ) . toBe ( PADDING_NO_SORT_ICON + 'longer string' . length * 10 ) ;
3641 } ) ;
3742
3843 it ( 'uses column name length when all values are shorter' , ( ) => {
3944 const data = [ { longColumnName : 'a' } , { longColumnName : 'bb' } ] ;
4045 const result = getColumnWidth ( { data, name : 'longColumnName' , columnType : 'string' } ) ;
41- expect ( result ) . toBe ( 20 + 'longColumnName' . length * 10 ) ;
46+ expect ( result ) . toBe ( PADDING_NO_SORT_ICON + 'longColumnName' . length * 10 ) ;
4247 } ) ;
4348} ) ;
0 commit comments