diff --git a/projects/kit/components/calendar-range/test/calendar-range.component.spec.ts b/projects/kit/components/calendar-range/test/calendar-range.component.spec.ts index 647c0d4a2206d..1853b095c7828 100644 --- a/projects/kit/components/calendar-range/test/calendar-range.component.spec.ts +++ b/projects/kit/components/calendar-range/test/calendar-range.component.spec.ts @@ -17,6 +17,7 @@ import { TuiDayRange, TuiMonth, TuiYear, + type TuiDayLike, } from '@taiga-ui/cdk'; import type {TuiMarkerHandler} from '@taiga-ui/core'; import {NG_EVENT_PLUGINS} from '@taiga-ui/event-plugins'; @@ -40,7 +41,9 @@ describe('rangeCalendarComponent', () => { [items]="items" [markerHandler]="markerHandler" [max]="max" + [maxLength]="maxLength" [min]="min" + [minLength]="minLength" [value]="value" (valueChange)="onRangeChange($event)" /> @@ -72,6 +75,10 @@ describe('rangeCalendarComponent', () => { public max = TUI_LAST_DAY; + public minLength: TuiDayLike | null = null; + + public maxLength: TuiDayLike | null = null; + public value: TuiDayRange | null = null; public defaultViewedMonth = TuiMonth.currentLocal(); @@ -254,6 +261,23 @@ describe('rangeCalendarComponent', () => { expect(items[1]?.nativeElement.contains(getCheckmark())).toBe(true); }); + it('Show item if it matches with minLength and maxLength', () => { + const today = TuiDay.currentLocal(); + const length = {day: 1}; + const title = 'Период'; + + testComponent.minLength = length; + testComponent.maxLength = length; + + testComponent.items = [ + new TuiDayRangePeriod(new TuiDayRange(today, today), title), + ]; + + fixture.detectChanges(); + + expect(getItems()[0]?.nativeElement.textContent.trim()).toBe(title); + }); + it('should update selectedActivePeriod after onItemSelect', () => { if (component.items[1]) { component['onItemSelect'](component.items[1]);