Skip to content

Commit

Permalink
chore(kit): CalendarRange add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 19, 2024
1 parent ff5822e commit 0bf93cc
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
TuiDayRange,
TuiMonth,
TuiYear,
type TuiDayLike,

Check failure on line 20 in projects/kit/components/calendar-range/test/calendar-range.component.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Prefer using a top-level type-only import instead of inline type specifiers
} from '@taiga-ui/cdk';
import type {TuiMarkerHandler} from '@taiga-ui/core';
import {NG_EVENT_PLUGINS} from '@taiga-ui/event-plugins';
Expand All @@ -40,7 +41,9 @@ describe('rangeCalendarComponent', () => {
[items]="items"
[markerHandler]="markerHandler"
[max]="max"
[maxLength]="maxLength"
[min]="min"
[minLength]="minLength"
[value]="value"
(valueChange)="onRangeChange($event)"
/>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -254,6 +261,23 @@ describe('rangeCalendarComponent', () => {
expect(items[1]?.nativeElement.contains(getCheckmark())).toBe(true);
});

it('Show item if it matches with minLength and maxLength', () => {

Check failure on line 264 in projects/kit/components/calendar-range/test/calendar-range.component.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

`it`s should begin with lowercase
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]);
Expand Down

0 comments on commit 0bf93cc

Please sign in to comment.