@@ -47,28 +47,28 @@ describe('sparkline.utils', () => {
4747 } ) ;
4848
4949 it ( 'includes zero in the domain when includeZero is true' , ( ) => {
50- expect ( calculateDomain ( [ 10 , 20 , 15 ] , undefined , undefined , true ) ) . toEqual ( { min : 0 , max : 20 } ) ;
50+ expect ( calculateDomain ( [ 10 , 20 , 15 ] , { includeZero : true } ) ) . toEqual ( { min : 0 , max : 20 } ) ;
5151 } ) ;
5252
5353 it ( 'returns the observed range when data includes negatives' , ( ) => {
5454 expect ( calculateDomain ( [ 5 , - 3 , 2 ] ) ) . toEqual ( { min : - 3 , max : 5 } ) ;
5555 } ) ;
5656
5757 it ( 'uses explicit min/max overrides even when data exceeds those bounds' , ( ) => {
58- expect ( calculateDomain ( [ - 100 , 50 , 200 ] , - 10 , 10 ) ) . toEqual ( { min : - 10 , max : 10 } ) ;
59- expect ( calculateDomain ( [ 5 , - 3 , 2 ] , - 10 , undefined ) ) . toEqual ( { min : - 10 , max : 5 } ) ;
60- expect ( calculateDomain ( [ 5 , - 3 , 2 ] , undefined , 10 ) ) . toEqual ( { min : - 3 , max : 10 } ) ;
58+ expect ( calculateDomain ( [ - 100 , 50 , 200 ] , { explicitMin : - 10 , explicitMax : 10 } ) ) . toEqual ( { min : - 10 , max : 10 } ) ;
59+ expect ( calculateDomain ( [ 5 , - 3 , 2 ] , { explicitMin : - 10 } ) ) . toEqual ( { min : - 10 , max : 5 } ) ;
60+ expect ( calculateDomain ( [ 5 , - 3 , 2 ] , { explicitMax : 10 } ) ) . toEqual ( { min : - 3 , max : 10 } ) ;
6161 } ) ;
6262 } ) ;
6363
6464 describe ( 'plot and symbol helpers' , ( ) => {
6565 it ( 'maps values to plot points and handles zero-range values' , ( ) => {
66- const points = toPlotPoints ( [ 5 , 5 ] , 5 , 5 , 120 ) ;
66+ const points = toPlotPoints ( [ 5 , 5 ] , { min : 5 , max : 5 } , { width : 120 } ) ;
6767 expect ( points ) . toEqual ( [
6868 { x : 0 , y : 50 } ,
6969 { x : 120 , y : 50 }
7070 ] ) ;
71- expect ( valueToY ( 5 , 5 , 5 ) ) . toBe ( 50 ) ;
71+ expect ( valueToY ( 5 , { min : 5 , max : 5 } ) ) . toBe ( 50 ) ;
7272 } ) ;
7373
7474 it ( 'resolves symbol indices for all boolean flag permutations' , ( ) => {
@@ -93,14 +93,14 @@ describe('sparkline.utils', () => {
9393 ] as const ;
9494
9595 for ( const { flags, expected } of cases ) {
96- const [ denoteFirst , denoteLast , denoteMin , denoteMax ] = flags ;
97- const actual = Array . from ( calculateSymbolIndices ( values , denoteFirst , denoteLast , denoteMin , denoteMax ) ) ;
96+ const [ first , last , min , max ] = flags ;
97+ const actual = Array . from ( calculateSymbolIndices ( values , { first , last , min , max } ) ) ;
9898 expect ( actual ) . toEqual ( expected ) ;
9999 }
100100 } ) ;
101101
102102 it ( 'returns no symbol indices for empty values' , ( ) => {
103- expect ( Array . from ( calculateSymbolIndices ( [ ] , true , true , true , true ) ) ) . toEqual ( [ ] ) ;
103+ expect ( Array . from ( calculateSymbolIndices ( [ ] , { first : true , last : true , min : true , max : true } ) ) ) . toEqual ( [ ] ) ;
104104 } ) ;
105105 } ) ;
106106
@@ -183,7 +183,7 @@ describe('sparkline.utils', () => {
183183
184184 describe ( 'winloss rect builders' , ( ) => {
185185 it ( 'builds winloss rects with expected class and geometry' , ( ) => {
186- const winlossRects = toWinLossRects ( [ 1 , 0 , - 1 ] , 50 , 180 , 100 ) ;
186+ const winlossRects = toWinLossRects ( [ 1 , 0 , - 1 ] , 50 , { width : 180 , height : 100 } ) ;
187187 expect ( winlossRects ) . toEqual ( [
188188 { className : 'win' , x : 4.5 , y : 0 , width : 51 , height : 50 } ,
189189 { className : 'draw' , x : 64.5 , y : 37.5 , width : 51 , height : 25 } ,
@@ -192,12 +192,12 @@ describe('sparkline.utils', () => {
192192 } ) ;
193193
194194 it ( 'centers a single winloss bar with the expected width' , ( ) => {
195- const [ winlossRect ] = toWinLossRects ( [ 1 ] , 50 , 60 , 100 ) ;
195+ const [ winlossRect ] = toWinLossRects ( [ 1 ] , 50 , { width : 60 , height : 100 } ) ;
196196 expect ( winlossRect ) . toEqual ( { className : 'win' , x : 4.5 , y : 0 , width : 51 , height : 50 } ) ;
197197 } ) ;
198198
199199 it ( 'returns no rects for empty winloss inputs' , ( ) => {
200- expect ( toWinLossRects ( [ ] , 50 , 120 , 100 ) ) . toEqual ( [ ] ) ;
200+ expect ( toWinLossRects ( [ ] , 50 , { width : 120 , height : 100 } ) ) . toEqual ( [ ] ) ;
201201 } ) ;
202202 } ) ;
203203} ) ;
0 commit comments