@@ -35,6 +35,7 @@ import {
35
35
[timeSelection]="timeSelection"
36
36
[startStepAxisPosition]="getAxisPositionFromStartStep()"
37
37
[endStepAxisPosition]="getAxisPositionFromEndStep()"
38
+ [prospectiveStepAxisPosition]="getAxisPositionFromProspectiveStep()"
38
39
[highestStep]="highestStep"
39
40
[lowestStep]="lowestStep"
40
41
[cardFobHelper]="cardFobHelper"
@@ -58,6 +59,7 @@ class TestableComponent {
58
59
@Input ( ) lowestStep ! : number ;
59
60
@Input ( ) getAxisPositionFromStartStep ! : ( ) => number ;
60
61
@Input ( ) getAxisPositionFromEndStep ! : ( ) => number ;
62
+ @Input ( ) getAxisPositionFromProspectiveStep ! : ( ) => number ;
61
63
@Input ( ) isProspectiveFobFeatureEnabled ! : Boolean ;
62
64
@Input ( ) prospectiveStep ! : number | null ;
63
65
@@ -72,6 +74,7 @@ describe('card_fob_controller', () => {
72
74
let getStepLowerSpy : jasmine . Spy ;
73
75
let getAxisPositionFromStartStepSpy : jasmine . Spy ;
74
76
let getAxisPositionFromEndStepSpy : jasmine . Spy ;
77
+ let getAxisPositionFromProspectiveStepSpy : jasmine . Spy ;
75
78
let cardFobHelper : CardFobGetStepFromPositionHelper ;
76
79
beforeEach ( async ( ) => {
77
80
await TestBed . configureTestingModule ( {
@@ -104,6 +107,7 @@ describe('card_fob_controller', () => {
104
107
getStepLowerSpy = jasmine . createSpy ( ) ;
105
108
getAxisPositionFromStartStepSpy = jasmine . createSpy ( ) ;
106
109
getAxisPositionFromEndStepSpy = jasmine . createSpy ( ) ;
110
+ getAxisPositionFromProspectiveStepSpy = jasmine . createSpy ( ) ;
107
111
getStepHigherSpy . and . callFake ( ( step : number ) => {
108
112
return step ;
109
113
} ) ;
@@ -118,6 +122,11 @@ describe('card_fob_controller', () => {
118
122
? fixture . componentInstance . timeSelection . end . step
119
123
: null ;
120
124
} ) ;
125
+ getAxisPositionFromProspectiveStepSpy . and . callFake ( ( ) => {
126
+ return fixture . componentInstance . prospectiveStep
127
+ ? fixture . componentInstance . prospectiveStep
128
+ : null ;
129
+ } ) ;
121
130
cardFobHelper = {
122
131
getStepHigherThanAxisPosition : getStepHigherSpy ,
123
132
getStepLowerThanAxisPosition : getStepLowerSpy ,
@@ -127,6 +136,8 @@ describe('card_fob_controller', () => {
127
136
getAxisPositionFromStartStepSpy ;
128
137
fixture . componentInstance . getAxisPositionFromEndStep =
129
138
getAxisPositionFromEndStepSpy ;
139
+ fixture . componentInstance . getAxisPositionFromProspectiveStep =
140
+ getAxisPositionFromProspectiveStepSpy ;
130
141
fixture . componentInstance . highestStep = 4 ;
131
142
fixture . componentInstance . lowestStep = 0 ;
132
143
fixture . componentInstance . cardFobHelper = cardFobHelper ;
@@ -1320,5 +1331,39 @@ describe('card_fob_controller', () => {
1320
1331
fixture . componentInstance . fobController . prospectiveFobWrapper
1321
1332
) . toBeUndefined ( ) ;
1322
1333
} ) ;
1334
+
1335
+ it ( 'sets horizontal position based on prospective step' , ( ) => {
1336
+ const fixture = createComponent ( {
1337
+ timeSelection : { start : { step : 4 } , end : null } ,
1338
+ axisDirection : AxisDirection . HORIZONTAL ,
1339
+ isProspectiveFobFeatureEnabled : true ,
1340
+ prospectiveStep : 2 ,
1341
+ } ) ;
1342
+ fixture . detectChanges ( ) ;
1343
+
1344
+ const fobController = fixture . componentInstance . fobController ;
1345
+ const prospectiveFobLeftPosition =
1346
+ fobController . prospectiveFobWrapper . nativeElement . getBoundingClientRect ( )
1347
+ . left ;
1348
+
1349
+ expect ( prospectiveFobLeftPosition ) . toEqual ( 2 ) ;
1350
+ } ) ;
1351
+
1352
+ it ( 'sets vertical position based on prospective step' , ( ) => {
1353
+ const fixture = createComponent ( {
1354
+ timeSelection : { start : { step : 4 } , end : null } ,
1355
+ axisDirection : AxisDirection . VERTICAL ,
1356
+ isProspectiveFobFeatureEnabled : true ,
1357
+ prospectiveStep : 2 ,
1358
+ } ) ;
1359
+ fixture . detectChanges ( ) ;
1360
+
1361
+ const fobController = fixture . componentInstance . fobController ;
1362
+ const prospectiveFobTopPosition =
1363
+ fobController . prospectiveFobWrapper . nativeElement . getBoundingClientRect ( )
1364
+ . top ;
1365
+
1366
+ expect ( prospectiveFobTopPosition ) . toEqual ( 2 ) ;
1367
+ } ) ;
1323
1368
} ) ;
1324
1369
} ) ;
0 commit comments