Skip to content

Commit 7007936

Browse files
committed
TT-107 fix: resolve comments
1 parent 8411391 commit 7007936

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/app/modules/shared/components/month-picker/month-picker.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</div>
1313

1414
<div class="col-sm-4 text-right">
15-
<button *ngIf="selectedYear < currentYear" class="btn ml-auto" (click)="changeYear('add')">
15+
<button *ngIf="showArrowNext" class="btn ml-auto" (click)="changeYear('add')">
1616
<i class="fa fa-chevron-right"></i>
1717
</button>
1818
</div>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ describe('MonthPickerComponent', () => {
4444
expect(component.changeYear).toHaveBeenCalled();
4545
expect(component.selectedYearText).toEqual(incrementYear);
4646
expect(component.selectedYearMoment.format('Y')).toEqual(incrementYear);
47+
expect(component.showArrowNext).toEqual(false);
4748
});
4849

49-
5050
it('should subtract a year to current year', () => {
5151
component.selectedYearMoment = moment();
5252
const decrementYear = moment().subtract(1, 'year').format('Y');
@@ -58,12 +58,13 @@ describe('MonthPickerComponent', () => {
5858
expect(component.selectedYearMoment.format('Y')).toEqual(decrementYear);
5959
});
6060

61-
6261
it('selectMonth should call selectDate', () => {
6362
component.selectedYear = 2020;
6463
spyOn(component, 'selectDate');
65-
component.selectMonth(1);
66-
expect(component.selectDate).toHaveBeenCalledWith(1, 2021);
64+
const monthSelect = new Date().getMonth();
65+
const yearSelect = new Date().getFullYear();
66+
component.selectMonth(monthSelect);
67+
expect(component.selectDate).toHaveBeenCalledWith(monthSelect, yearSelect);
6768
});
6869

6970
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class MonthPickerComponent implements OnInit {
1818
selectedYear: number;
1919
selectedYearText: string;
2020
months: Array<string> = [];
21-
2221
currentYear = new Date().getFullYear();
22+
showArrowNext = false;
2323

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

4242
const monthIndex = changeAction === 'add' ? 0 : 11;
4343
this.selectMonth(monthIndex);
44+
45+
this.showArrowNext = this.selectedYear < this.currentYear ?? !this.showArrowNext;
4446
}
4547

4648
selectMonth(monthIndex: number) {

0 commit comments

Comments
 (0)