Skip to content

Commit 42aea4b

Browse files
scastillo-jpGuido Quezada
authored andcommitted
TT-39 fix: testing increment() and decrement()
1 parent d472a63 commit 42aea4b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/app/modules/shared/components/month-picker/month-picker.component.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)