Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TT-107 fix: resolve comments
  • Loading branch information
scastillo-jp committed Jan 5, 2021
commit c51e9d2e867b7fc8538855b6b194ec4ae0d02ec9
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>

<div class="col-sm-4 text-right">
<button *ngIf="selectedYear < currentYear" class="btn ml-auto" (click)="changeYear('add')">
<button *ngIf="showArrowNext" class="btn ml-auto" (click)="changeYear('add')">
<i class="fa fa-chevron-right"></i>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ describe('MonthPickerComponent', () => {
expect(component.changeYear).toHaveBeenCalled();
expect(component.selectedYearText).toEqual(incrementYear);
expect(component.selectedYearMoment.format('Y')).toEqual(incrementYear);
expect(component.showArrowNext).toEqual(false);
});


it('should subtract a year to current year', () => {
component.selectedYearMoment = moment();
const decrementYear = moment().subtract(1, 'year').format('Y');
Expand All @@ -58,12 +58,13 @@ describe('MonthPickerComponent', () => {
expect(component.selectedYearMoment.format('Y')).toEqual(decrementYear);
});


it('selectMonth should call selectDate', () => {
component.selectedYear = 2020;
spyOn(component, 'selectDate');
component.selectMonth(1);
expect(component.selectDate).toHaveBeenCalledWith(1, 2021);
const monthSelect = new Date().getMonth();
const yearSelect = new Date().getFullYear();
component.selectMonth(monthSelect);
expect(component.selectDate).toHaveBeenCalledWith(monthSelect, yearSelect);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export class MonthPickerComponent implements OnInit {
selectedYear: number;
selectedYearText: string;
months: Array<string> = [];

currentYear = new Date().getFullYear();
showArrowNext = false;

constructor() {
this.selectedYearMoment = moment();
Expand All @@ -41,6 +41,8 @@ export class MonthPickerComponent implements OnInit {

const monthIndex = changeAction === 'add' ? 0 : 11;
this.selectMonth(monthIndex);

this.showArrowNext = this.selectedYear < this.currentYear ?? !this.showArrowNext;
}

selectMonth(monthIndex: number) {
Expand Down