@@ -7,14 +7,18 @@ describe('Linear Scale with Breaks', () => {
77 breaks : [ { start : 40 , end : 100 , gap : 0.1 } ] ,
88 } ) ;
99
10- const { domain, range, round, tickCount, nice, clamp, unknown } = scale . getOptions ( ) ;
10+ const { domain, range, round, tickCount, nice, clamp, unknown, tickMethod } = scale . getOptions ( ) as Record <
11+ string ,
12+ any
13+ > ;
1114 expect ( domain ) . toStrictEqual ( [ 0 , 40 , 100 , 150 , 200 ] ) ;
1215 expect ( range ) . toStrictEqual ( [ 1 , 0.7000000000000001 , 0.6 , 0.25 , 0 ] ) ;
1316 expect ( round ) . toBeFalsy ( ) ;
1417 expect ( tickCount ) . toStrictEqual ( 5 ) ;
1518 expect ( nice ) . toBeFalsy ( ) ;
1619 expect ( clamp ) . toBeFalsy ( ) ;
1720 expect ( unknown ) . toBeUndefined ( ) ;
21+ expect ( tickMethod ( 0 , 200 , 5 ) ) . toEqual ( domain ) ;
1822 } ) ;
1923
2024 test ( 'multiple breaks should compress multiple regions' , ( ) => {
@@ -78,6 +82,12 @@ describe('Linear Scale with Breaks', () => {
7882 const scaleOptions = scale . getOptions ( ) ;
7983 expect ( scaleOptions . domain ) . toStrictEqual ( [ 0 , 50 , 100 , 150 , 200 ] ) ;
8084 expect ( scaleOptions . range ) . toStrictEqual ( [ 1 , 0.75 , 0.5 , 0.25 , 0 ] ) ;
85+ scale . update ( {
86+ domain : [ 0 , 200 ] ,
87+ breaks : undefined ,
88+ } ) ;
89+ const scaleOptions2 = scale . getOptions ( ) ;
90+ expect ( scaleOptions2 . domain ) . toStrictEqual ( [ 0 , 200 ] ) ;
8191 } ) ;
8292
8393 test ( 'no breaks should behave like normal linear scale' , ( ) => {
@@ -89,4 +99,14 @@ describe('Linear Scale with Breaks', () => {
8999 expect ( domain ) . toStrictEqual ( [ 0 , 200 ] ) ;
90100 expect ( range ) . toStrictEqual ( [ 0 , 1 ] ) ;
91101 } ) ;
102+
103+ test ( 'linear scale with clone' , ( ) => {
104+ const scale = new Linear ( {
105+ domain : [ 0 , 200 ] ,
106+ } ) ;
107+
108+ const scale2 = scale . clone ( ) ;
109+ expect ( scale2 ) . toBeInstanceOf ( Linear ) ;
110+ expect ( scale2 . getOptions ( ) ) . toEqual ( scale . getOptions ( ) ) ;
111+ } ) ;
92112} ) ;
0 commit comments