File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def min
4646
4747 def max
4848 if @data . any? && values . last && values . last . any?
49+ return 0 if min < 0 && values . last . max <= 0
4950 closest_step_to values . last . max
5051 end
5152 end
Original file line number Diff line number Diff line change 9999 it { expect ( width ) . to eq 14 }
100100 end
101101 end
102+
103+ describe '#minmax' do
104+ subject ( :axis ) { Squid ::Axis . new series , options }
105+ let ( :minmax ) { axis . minmax }
106+
107+ describe 'given all-zero series' do
108+ let ( :series ) { [ 0 , 0 , 0 ] }
109+ it { expect ( minmax ) . to eq [ 0 , steps ] }
110+ end
111+
112+ describe 'given positive series' do
113+ let ( :series ) { [ 0 , 10 , 12 ] }
114+ it { expect ( minmax ) . to eq [ 0 , 12 ] }
115+ end
116+
117+ describe 'given negative series' do
118+ let ( :series ) { [ 0 , -10 , -12 ] }
119+ it { expect ( minmax ) . to eq [ -12 , 0 ] }
120+ end
121+
122+ describe 'given mixed series' do
123+ let ( :series ) { [ 0 , -10 , 12 ] }
124+ it { expect ( minmax ) . to eq [ -10 , 12 ] }
125+ end
126+ end
102127end
You can’t perform that action at this time.
0 commit comments