@@ -16,6 +16,7 @@ import {CardFobControllerComponent} from '../../../widgets/card_fob/card_fob_con
16
16
import { TimeSelection } from '../../../widgets/card_fob/card_fob_types' ;
17
17
import { LinearScale } from '../../../widgets/line_chart_v2/lib/scale' ;
18
18
import { ScalarCardFobController } from './scalar_card_fob_controller' ;
19
+ import { MinMaxStep } from './scalar_card_types' ;
19
20
20
21
const SCALE_RATIO = 10 ;
21
22
@@ -33,6 +34,7 @@ describe('ScalarFobController', () => {
33
34
function createComponent ( input : {
34
35
timeSelection ?: TimeSelection ;
35
36
minMax ?: [ number , number ] ;
37
+ minMaxStep ?: MinMaxStep ;
36
38
axisSize ?: number ;
37
39
} ) : ComponentFixture < ScalarCardFobController > {
38
40
const fixture = TestBed . createComponent ( ScalarCardFobController ) ;
@@ -41,7 +43,13 @@ describe('ScalarFobController', () => {
41
43
end : null ,
42
44
} ;
43
45
44
- fixture . componentInstance . minMax = input . minMax ?? [ 0 , 1 ] ;
46
+ fixture . componentInstance . minMaxHorizontalViewExtend = input . minMax ?? [
47
+ - 1 , 2 ,
48
+ ] ;
49
+ fixture . componentInstance . minMaxStep = input . minMaxStep ?? {
50
+ minStep : 0 ,
51
+ maxStep : 1 ,
52
+ } ;
45
53
fixture . componentInstance . axisSize = input . axisSize ?? 1 ;
46
54
47
55
const fakeScale = new LinearScale ( ) ;
@@ -89,56 +97,14 @@ describe('ScalarFobController', () => {
89
97
} ) ;
90
98
} ) ;
91
99
92
- describe ( 'getHighestStep' , ( ) => {
93
- it ( 'gets the highest step when minMax is in order' , ( ) => {
94
- const fixture = createComponent ( { minMax : [ 0 , 2 ] } ) ;
95
-
96
- const highestStep = fixture . componentInstance . getHighestStep ( ) ;
97
-
98
- expect ( highestStep ) . toBe ( 2 ) ;
99
- } ) ;
100
-
101
- it ( 'gets the highest step when minMax is not in order' , ( ) => {
102
- const fixture = createComponent ( { minMax : [ 2 , 0 ] } ) ;
103
-
104
- const highestStep = fixture . componentInstance . getHighestStep ( ) ;
100
+ it ( 'gets the highest/lowest step' , ( ) => {
101
+ const fixture = createComponent ( { minMaxStep : { minStep : 0 , maxStep : 2 } } ) ;
105
102
106
- expect ( highestStep ) . toBe ( 2 ) ;
107
- } ) ;
108
-
109
- it ( 'returns the next lowest step when max is a floating point.' , ( ) => {
110
- const fixture = createComponent ( { minMax : [ 4.5 , 1 ] } ) ;
111
-
112
- const lowestStep = fixture . componentInstance . getHighestStep ( ) ;
113
-
114
- expect ( lowestStep ) . toBe ( 4 ) ;
115
- } ) ;
116
- } ) ;
103
+ const highestStep = fixture . componentInstance . getHighestStep ( ) ;
104
+ const lowestStep = fixture . componentInstance . getLowestStep ( ) ;
117
105
118
- describe ( 'getLowestStep' , ( ) => {
119
- it ( 'gets the lowest step when minMax is in order' , ( ) => {
120
- const fixture = createComponent ( { minMax : [ 0 , 2 ] } ) ;
121
-
122
- const lowestStep = fixture . componentInstance . getLowestStep ( ) ;
123
-
124
- expect ( lowestStep ) . toBe ( 0 ) ;
125
- } ) ;
126
-
127
- it ( 'gets the lowest step when minMax is not in order' , ( ) => {
128
- const fixture = createComponent ( { minMax : [ 2 , 0 ] } ) ;
129
-
130
- const lowestStep = fixture . componentInstance . getLowestStep ( ) ;
131
-
132
- expect ( lowestStep ) . toBe ( 0 ) ;
133
- } ) ;
134
-
135
- it ( 'returns the next highest step when min is a floating point.' , ( ) => {
136
- const fixture = createComponent ( { minMax : [ 4 , 1.5 ] } ) ;
137
-
138
- const lowestStep = fixture . componentInstance . getLowestStep ( ) ;
139
-
140
- expect ( lowestStep ) . toBe ( 2 ) ;
141
- } ) ;
106
+ expect ( lowestStep ) . toBe ( 0 ) ;
107
+ expect ( highestStep ) . toBe ( 2 ) ;
142
108
} ) ;
143
109
144
110
describe ( 'getStepHigherThanAxisPosition' , ( ) => {
@@ -151,15 +117,15 @@ describe('ScalarFobController', () => {
151
117
} ) ;
152
118
153
119
it ( 'gets highest step if given position is higher than the position at highest step' , ( ) => {
154
- const fixture = createComponent ( { minMax : [ 0 , 2 ] } ) ;
120
+ const fixture = createComponent ( { minMaxStep : { minStep : 0 , maxStep : 2 } } ) ;
155
121
156
122
const step = fixture . componentInstance . getStepHigherThanAxisPosition ( 30 ) ;
157
123
158
124
expect ( step ) . toBe ( 2 ) ;
159
125
} ) ;
160
126
161
127
it ( 'gets lowest step if given position is lower than the position at lowest step' , ( ) => {
162
- const fixture = createComponent ( { minMax : [ 1 , 3 ] } ) ;
128
+ const fixture = createComponent ( { minMaxStep : { minStep : 1 , maxStep : 3 } } ) ;
163
129
164
130
const step = fixture . componentInstance . getStepHigherThanAxisPosition ( 0 ) ;
165
131
@@ -177,15 +143,15 @@ describe('ScalarFobController', () => {
177
143
} ) ;
178
144
179
145
it ( 'gets highest step if given position is higher than the position at highest step' , ( ) => {
180
- const fixture = createComponent ( { minMax : [ 0 , 2 ] } ) ;
146
+ const fixture = createComponent ( { minMaxStep : { minStep : 0 , maxStep : 2 } } ) ;
181
147
182
148
const step = fixture . componentInstance . getStepLowerThanAxisPosition ( 30 ) ;
183
149
184
150
expect ( step ) . toBe ( 2 ) ;
185
151
} ) ;
186
152
187
153
it ( 'gets lowest step if given position is lower than the position at lowest step' , ( ) => {
188
- const fixture = createComponent ( { minMax : [ 1 , 3 ] } ) ;
154
+ const fixture = createComponent ( { minMaxStep : { minStep : 1 , maxStep : 3 } } ) ;
189
155
190
156
const step = fixture . componentInstance . getStepLowerThanAxisPosition ( 0 ) ;
191
157
0 commit comments