Skip to content

Commit

Permalink
chore(kit): InputDate test update min checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 20, 2024
1 parent ed14441 commit 3154d57
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,17 @@ describe('InputDate', () => {
expect(typedDay.year).toBe(2021);
});

it('does not accept mm.dd.yyyy (and set min day if it is less min day)', () => {
it('does not accept mm.dd.yyyy (and set min day if it is less min day)', async () => {
inputPO.sendText('12.23.2021');

await fixture.whenStable();

const typedDay = testComponent.control.value;

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

it('sets valid day if date selected via calendar', async () => {
Expand Down Expand Up @@ -262,15 +264,17 @@ describe('InputDate', () => {
expect(typedDay.year).toBe(2021);
});

it('does not accept yyyy.mm.dd (and set min day if it is less min day)', () => {
it('does not accept yyyy.mm.dd (and set min day if it is less min day)', async () => {
inputPO.sendText('2021.12.23');

await fixture.whenStable();

const typedDay = testComponent.control.value;

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

it('sets valid day if date selected via calendar', async () => {
Expand Down Expand Up @@ -369,11 +373,13 @@ describe('InputDate', () => {
expect(testComponent.control.value).toEqual(new Date(1905, 0, 9));
});

it('transforms min day as output (if typed day is less than min day)', () => {
inputPO.sendText('19.02.1861');
it('transforms min day as output (if typed day is less than min day)', async () => {
inputPO.sendText('19.02.1300');

await fixture.whenStable();

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

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

0 comments on commit 3154d57

Please sign in to comment.