Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
435 changes: 435 additions & 0 deletions src/components/date-range-picker/date-range-input.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
type ValidationContainerTestsParams,
ValidityHelpers,
} from '../common/validity-helpers.spec.js';
import IgcInputComponent from '../input/input.js';
import type IgcDateRangeInputComponentComponent from './date-range-input.js';
import IgcDateRangeInputComponent from './date-range-input.js';
import IgcDateRangePickerComponent, {
type DateRangeValue,
} from './date-range-picker.js';
Expand All @@ -21,7 +22,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
before(() => defineComponents(IgcDateRangePickerComponent));

let picker: IgcDateRangePickerComponent;
let input: IgcInputComponent;
let input: IgcDateRangeInputComponentComponent;
let startKey = '';
let endKey = '';

Expand Down Expand Up @@ -67,24 +68,26 @@ describe('Date Range Picker Single Input - Form integration', () => {
await elementUpdated(spec.element);

input = picker.renderRoot.querySelector(
IgcInputComponent.tagName
) as IgcInputComponent;
IgcDateRangeInputComponent.tagName
) as IgcDateRangeInputComponent;

checkSelectedRange(spec.element, value, false);

spec.reset();
await elementUpdated(spec.element);

expect(spec.element.value).to.deep.equal(initial);
expect(input.value).to.equal('');
expect(input.value).to.deep.equal({ start: null, end: null });
});

it('should not be in invalid state on reset for a required control which previously had value', () => {
spec.setProperties({ value: value });
spec.setProperties({ required: true });

spec.assertSubmitPasses();
const input = picker.renderRoot.querySelector(IgcInputComponent.tagName)!;
const input = picker.renderRoot.querySelector(
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.false;

spec.setProperties({ value: null });
Expand All @@ -100,7 +103,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitFails();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.true;

Expand All @@ -118,10 +121,10 @@ describe('Date Range Picker Single Input - Form integration', () => {
await elementUpdated(spec.element);

input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
) as IgcInputComponent;
IgcDateRangeInputComponent.tagName
) as IgcDateRangeInputComponent;

expect(input.value).to.equal('');
expect(input.value).to.deep.equal({ start: null, end: null });

spec.reset();
await elementUpdated(spec.element);
Expand All @@ -146,7 +149,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitFails();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.true;

Expand All @@ -162,7 +165,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitPasses();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.false;

Expand Down Expand Up @@ -205,7 +208,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitPasses();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.false;

Expand Down Expand Up @@ -246,7 +249,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitPasses();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.false;

Expand Down Expand Up @@ -279,7 +282,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitPasses();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.false;

Expand Down Expand Up @@ -323,7 +326,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitFails();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.true;

Expand Down Expand Up @@ -383,7 +386,7 @@ describe('Date Range Picker Single Input - Form integration', () => {
spec.assertSubmitFails();
await elementUpdated(spec.element);
const input = spec.element.renderRoot.querySelector(
IgcInputComponent.tagName
IgcDateRangeInputComponent.tagName
)!;
expect(input.invalid).to.be.true;

Expand Down Expand Up @@ -416,8 +419,8 @@ describe('Date Range Picker Single Input - Form integration', () => {
html`<igc-date-range-picker required></igc-date-range-picker>`
);
const input = picker.renderRoot.querySelector(
IgcInputComponent.tagName
) as IgcInputComponent;
IgcDateRangeInputComponent.tagName
) as IgcDateRangeInputComponent;

expect(picker.invalid).to.be.false;
expect(input.invalid).to.be.false;
Expand Down
Loading