Skip to content

Commit

Permalink
chore(kit): InputDate update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 18, 2024
1 parent ee1be0a commit 4b6cfd5
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('InputDate', () => {

readOnly = false;

min = new TuiDay(1900, 0, 1);
min: TuiDay | null = new TuiDay(1500, 0, 1);

labelOutside = false;

Expand Down Expand Up @@ -125,6 +125,15 @@ describe('InputDate', () => {
expect(inputPO.value).toBe('14.03.2017');
});

it('correct shows value less than 01.01.1900', async () => {
testComponent.control.patchValue(new TuiDay(1000, 0, 1));
fixture.detectChanges();

await fixture.whenStable();

expect(inputPO.value).toBe('01.01.1000');
});

describe('Keyboard input', () => {
it('The passed date is inserted into the field', () => {
inputPO.sendText('01.03.2017');
Expand Down Expand Up @@ -211,10 +220,10 @@ describe('InputDate', () => {

const typedDay = testComponent.control.value;

expect(inputPO.value).toBe('1900.01.01');
expect(typedDay.day).toBe(1);
expect(typedDay.month).toBe(0);
expect(typedDay.year).toBe(1900);
expect(inputPO.value).toBe('1223.08.21');
expect(typedDay.day).toBe(21);
expect(typedDay.month).toBe(7);
expect(typedDay.year).toBe(1223);
});

it('sets valid day if date selected via calendar', async () => {
Expand Down Expand Up @@ -258,10 +267,10 @@ describe('InputDate', () => {

const typedDay = testComponent.control.value;

expect(inputPO.value).toBe('01.01.1900');
expect(typedDay.day).toBe(1);
expect(typedDay.month).toBe(0);
expect(typedDay.year).toBe(1900);
expect(inputPO.value).toBe('08.21.1223');
expect(typedDay.day).toBe(21);
expect(typedDay.month).toBe(7);
expect(typedDay.year).toBe(1223);
});

it('sets valid day if date selected via calendar', async () => {
Expand Down Expand Up @@ -363,8 +372,8 @@ describe('InputDate', () => {
it('transforms min day as output (if typed day is less than min day)', () => {
inputPO.sendText('19.02.1861');

expect(inputPO.value).toBe('01.01.1900');
expect(testComponent.control.value).toEqual(new Date(1900, 0, 1));
expect(inputPO.value).toBe('19.02.1861');
expect(testComponent.control.value).toEqual(new Date(1861, 1, 19));
});

it('transforms value which was selected via calendar', async () => {
Expand Down

0 comments on commit 4b6cfd5

Please sign in to comment.