@@ -34,15 +34,27 @@ describe('MonthPickerComponent', () => {
3434 } ) ;
3535
3636 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 ) ;
4046 } ) ;
4147
48+
4249 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 ) ;
4658 } ) ;
4759
4860} ) ;
0 commit comments