@@ -34,15 +34,27 @@ describe('MonthPickerComponent', () => {
34
34
} ) ;
35
35
36
36
it ( 'should add a year to current year' , ( ) => {
37
- const year = moment ( ) . add ( 1 , 'year' ) . format ( 'Y' ) ;
38
- expect ( component . selectedYearMoment . add ( 1 , 'year' ) . format ( 'Y' ) ) . toEqual ( year ) ;
39
- expect ( component . updateYearText ) . toBeTruthy ( ) ;
37
+ component . selectedYearMoment = moment ( ) ;
38
+ const incrementYear = moment ( ) . add ( 1 , 'year' ) . format ( 'Y' ) ;
39
+ spyOn ( component , 'increment' ) . and . callThrough ( ) ;
40
+
41
+ component . increment ( ) ;
42
+
43
+ expect ( component . increment ) . toHaveBeenCalled ( ) ;
44
+ expect ( component . selectedYearText ) . toEqual ( incrementYear ) ;
45
+ expect ( component . selectedYearMoment . format ( 'Y' ) ) . toEqual ( incrementYear ) ;
40
46
} ) ;
41
47
48
+
42
49
it ( 'should subtract a year to current year' , ( ) => {
43
- const year = moment ( ) . subtract ( 1 , 'year' ) . format ( 'Y' ) ;
44
- expect ( component . selectedYearMoment . subtract ( 1 , 'year' ) . format ( 'Y' ) ) . toEqual ( year ) ;
45
- expect ( component . updateYearText ) . toBeTruthy ( ) ;
50
+ component . selectedYearMoment = moment ( ) ;
51
+ const decrementYear = moment ( ) . subtract ( 1 , 'year' ) . format ( 'Y' ) ;
52
+ spyOn ( component , 'decrement' ) . and . callThrough ( ) ;
53
+
54
+ component . decrement ( ) ;
55
+
56
+ expect ( component . decrement ) . toHaveBeenCalled ( ) ;
57
+ expect ( component . selectedYearMoment . format ( 'Y' ) ) . toEqual ( decrementYear ) ;
46
58
} ) ;
47
59
48
60
} ) ;
0 commit comments