Skip to content

Commit

Permalink
fix(kit): CalendarRange not switch month with selected value (#9695)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy authored Nov 6, 2024
1 parent 755d517 commit 0e5f250
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ test.describe('CalendarRange', () => {
'05-calendar-range-correct-display-defaults-items-and-values.png',
);
});

test.describe('With value', () => {
test('Month switching via chevron', async () => {
example = documentationPage.getExample('#with-value');
calendarRange = new TuiCalendarRangePO(
example.locator('tui-calendar-range'),
);

const getPreviousMonthChevron = (): Locator =>
example.locator('tui-spin-button > button').first();

await getPreviousMonthChevron().click();

await expect(example).toHaveScreenshot(
'07-calendar-range-with-value-click-chevron.png',
);
});
});
});

test.describe('API', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class TuiCalendarRange implements OnInit, OnChanges {
}

protected onMonthChange(month: TuiMonth): void {
this.defaultViewedMonth = month;
this.month = month;
}

protected onDayClick(day: TuiDay): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ describe('rangeCalendarComponent', () => {

expect(component.defaultViewedMonth.toString()).toBe(defaultMonth.toString());
});

it('if value selected, updating defaultViewedMonth via chevron change viewed month', () => {
testComponent.value = new TuiDayRange(
TuiDay.currentLocal().append({month: 1}),
TuiDay.currentLocal().append({month: 1}),
);
fixture.detectChanges();

component['onMonthChange'](updatedMonth);
fixture.detectChanges();

expect(component.defaultViewedMonth.toString()).toBe(updatedMonth.toString());
});
});

function getCalendar(): DebugElement | null {
Expand Down

0 comments on commit 0e5f250

Please sign in to comment.