@@ -126,17 +126,55 @@ describe('utils/domain', () => {
126126 expect ( stackedDataDomain ) . toEqual ( expectedStackedDomain ) ;
127127 } ) ;
128128
129- test ( 'should compute domain based on scaleToExtent' , ( ) => {
130- // start & end are positive
131- expect ( computeDomainExtent ( [ 5 , 10 ] , true ) ) . toEqual ( [ 5 , 10 ] ) ;
132- expect ( computeDomainExtent ( [ 5 , 10 ] , false ) ) . toEqual ( [ 0 , 10 ] ) ;
133-
134- // start & end are negative
135- expect ( computeDomainExtent ( [ - 15 , - 10 ] , true ) ) . toEqual ( [ - 15 , - 10 ] ) ;
136- expect ( computeDomainExtent ( [ - 15 , - 10 ] , false ) ) . toEqual ( [ - 15 , 0 ] ) ;
137-
138- // start is negative, end is positive
139- expect ( computeDomainExtent ( [ - 15 , 10 ] , true ) ) . toEqual ( [ - 15 , 10 ] ) ;
140- expect ( computeDomainExtent ( [ - 15 , 10 ] , false ) ) . toEqual ( [ - 15 , 10 ] ) ;
129+ describe ( 'scaleToExtent' , ( ) => {
130+ describe ( 'true' , ( ) => {
131+ it ( 'should find domain when start & end are positive' , ( ) => {
132+ expect ( computeDomainExtent ( [ 5 , 10 ] , true ) ) . toEqual ( [ 5 , 10 ] ) ;
133+ } ) ;
134+ it ( 'should find domain when start & end are negative' , ( ) => {
135+ expect ( computeDomainExtent ( [ - 15 , - 10 ] , true ) ) . toEqual ( [ - 15 , - 10 ] ) ;
136+ } ) ;
137+ it ( 'should find domain when start is negative, end is positive' , ( ) => {
138+ expect ( computeDomainExtent ( [ - 15 , 10 ] , true ) ) . toEqual ( [ - 15 , 10 ] ) ;
139+ } ) ;
140+ } ) ;
141+ describe ( 'false' , ( ) => {
142+ it ( 'should find domain when start & end are positive' , ( ) => {
143+ expect ( computeDomainExtent ( [ 5 , 10 ] , false ) ) . toEqual ( [ 0 , 10 ] ) ;
144+ } ) ;
145+ it ( 'should find domain when start & end are negative' , ( ) => {
146+ expect ( computeDomainExtent ( [ - 15 , - 10 ] , false ) ) . toEqual ( [ - 15 , 0 ] ) ;
147+ } ) ;
148+ it ( 'should find domain when start is negative, end is positive' , ( ) => {
149+ expect ( computeDomainExtent ( [ - 15 , 10 ] , false ) ) . toEqual ( [ - 15 , 10 ] ) ;
150+ } ) ;
151+ } ) ;
152+ } ) ;
153+
154+ describe ( 'fitToExtent' , ( ) => {
155+ it ( 'should not effect domain when scaleToExtent is true' , ( ) => {
156+ expect ( computeDomainExtent ( [ 5 , 10 ] , true ) ) . toEqual ( [ 5 , 10 ] ) ;
157+ } ) ;
158+
159+ describe ( 'baseline far from zero' , ( ) => {
160+ it ( 'should get domain from positive domain' , ( ) => {
161+ expect ( computeDomainExtent ( [ 10 , 70 ] , false , true ) ) . toEqual ( [ 5 , 75 ] ) ;
162+ } ) ;
163+ it ( 'should get domain from positive & negative domain' , ( ) => {
164+ expect ( computeDomainExtent ( [ - 30 , 30 ] , false , true ) ) . toEqual ( [ - 35 , 35 ] ) ;
165+ } ) ;
166+ it ( 'should get domain from negative domain' , ( ) => {
167+ expect ( computeDomainExtent ( [ - 70 , - 10 ] , false , true ) ) . toEqual ( [ - 75 , - 5 ] ) ;
168+ } ) ;
169+ } ) ;
170+
171+ describe ( 'baseline near zero' , ( ) => {
172+ it ( 'should set min baseline as 0 if original domain is less than zero' , ( ) => {
173+ expect ( computeDomainExtent ( [ 5 , 65 ] , false , true ) ) . toEqual ( [ 0 , 70 ] ) ;
174+ } ) ;
175+ it ( 'should set max baseline as 0 if original domain is less than zero' , ( ) => {
176+ expect ( computeDomainExtent ( [ - 65 , - 5 ] , false , true ) ) . toEqual ( [ - 70 , 0 ] ) ;
177+ } ) ;
178+ } ) ;
141179 } ) ;
142180} ) ;
0 commit comments