From d94be47ec3f397acd035d76bf028809b68b439d0 Mon Sep 17 00:00:00 2001 From: SheenaMalhotra182 Date: Wed, 23 Aug 2023 19:09:01 +0530 Subject: [PATCH] [ACS-5857] modified unit tests --- .../lib/form/components/form-renderer.component.spec.ts | 8 ++++---- .../form/components/mock/form-renderer.component.mock.ts | 6 +++--- .../components/widgets/date/date-cloud.widget.spec.ts | 8 ++++---- .../lib/form/components/widgets/date/date-cloud.widget.ts | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/core/src/lib/form/components/form-renderer.component.spec.ts b/lib/core/src/lib/form/components/form-renderer.component.spec.ts index cb759143a3..587d019e0e 100644 --- a/lib/core/src/lib/form/components/form-renderer.component.spec.ts +++ b/lib/core/src/lib/form/components/form-renderer.component.spec.ts @@ -123,13 +123,13 @@ describe('Form Renderer Component', () => { let displayTextElementContainer: HTMLInputElement = fixture.nativeElement.querySelector('#field-Text0pqd1u-container'); expectElementToBeHidden(displayTextElementContainer); - const formattedDate = format(new Date('2019-11-19'), 'd-M-yyyy'); + const formattedDate = format(new Date('2019-11-19'), 'yyyy-M-d'); typeIntoDate(inputDateTestOne, { srcElement: { value: formattedDate } }); fixture.detectChanges(); await fixture.whenStable(); - displayTextElementContainer = fixture.nativeElement.querySelector('#field-Text0uyqd3-container'); + displayTextElementContainer = fixture.nativeElement.querySelector('#field-Text0pqd1u-container'); expectElementToBeVisible(displayTextElementContainer); }); @@ -142,13 +142,13 @@ describe('Form Renderer Component', () => { let displayTextElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-Text0uyqd3-container'); expectElementToBeVisible(displayTextElementContainer); - const formattedDate = format(new Date('2019-11-19'), 'd-M-yyyy'); + const formattedDate = format(new Date('2019-11-19'), 'yyyy-M-d'); typeIntoDate(inputDateTestOne, { srcElement: { value: formattedDate } }); fixture.detectChanges(); await fixture.whenStable(); - displayTextElementContainer = fixture.nativeElement.querySelector('#field-Text0pqd1u-container'); + displayTextElementContainer = fixture.nativeElement.querySelector('#field-Text0uyqd3-container'); expectElementToBeHidden(displayTextElementContainer); }); diff --git a/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts b/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts index 72038214d3..cfeb7a11ca 100644 --- a/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts +++ b/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts @@ -1505,7 +1505,7 @@ export const formDateVisibility = { existingColspan: 1, maxColspan: 2 }, - dateDisplayFormat: 'd-M-yyyy' + dateDisplayFormat: 'yyyy-M-d' } ], 2: [ @@ -1525,7 +1525,7 @@ export const formDateVisibility = { leftType: 'field', leftValue: 'Date0hwq20', operator: '==', - rightValue: '19-11-2019', + rightValue: '2019-11-19', rightType: 'value', nextConditionOperator: '', nextCondition: null @@ -1562,7 +1562,7 @@ export const formDateVisibility = { leftType: 'field', leftValue: 'Date0hwq20', operator: '!=', - rightValue: '19-11-2019', + rightValue: '2019-11-19', rightType: 'value', nextConditionOperator: '', nextCondition: null diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts index ca2b16c7d2..8e13c9993c 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.spec.ts @@ -392,7 +392,7 @@ describe('DateWidgetComponent', () => { describe('check date validation by dynamic date ranges', () => { it('should minValue be equal to today date minus minDateRangeValue', async () => { - spyOn(widget, 'getTodaysFormattedDate').and.returnValue(new Date('2022-07-22')); + spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22')); widget.field = new FormFieldModel(null, { dynamicDateRangeSelection: true, maxDateRangeValue: null, @@ -412,7 +412,7 @@ describe('DateWidgetComponent', () => { }); it('should maxValue be equal to today date plus maxDateRangeValue', async () => { - spyOn(widget, 'getTodaysFormattedDate').and.returnValue(new Date('2022-07-22')); + spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22')); widget.field = new FormFieldModel(null, { dynamicDateRangeSelection: true, maxDateRangeValue: 8, @@ -432,7 +432,7 @@ describe('DateWidgetComponent', () => { }); it('should maxValue and minValue be null if maxDateRangeValue and minDateRangeValue are null', async () => { - spyOn(widget, 'getTodaysFormattedDate').and.returnValue(new Date('22-07-2022')); + spyOn(widget, 'getTodaysDate').and.returnValue(new Date('22-07-2022')); widget.field = new FormFieldModel(null, { dynamicDateRangeSelection: true, maxDateRangeValue: null, @@ -451,7 +451,7 @@ describe('DateWidgetComponent', () => { }); it('should maxValue and minValue not be null if maxDateRangeVale and minDateRangeValue are not null', async () => { - spyOn(widget, 'getTodaysFormattedDate').and.returnValue(new Date('2022-07-22')); + spyOn(widget, 'getTodaysDate').and.returnValue(new Date('2022-07-22')); widget.field = new FormFieldModel(null, { dynamicDateRangeSelection: true, maxDateRangeValue: 8, diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts index 54b06184c0..c19afeba84 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/date/date-cloud.widget.ts @@ -71,7 +71,7 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, if (this.field) { if (this.field.dynamicDateRangeSelection) { - const today = this.getTodaysFormattedDate(); + const today = this.getTodaysDate(); if (Number.isInteger(this.field.minDateRangeValue)) { this.minDate = format(subDays(today, this.field.minDateRangeValue), DATE_FORMAT_CLOUD); this.field.minValue = this.minDate; @@ -93,7 +93,7 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, } } - getTodaysFormattedDate() { + getTodaysDate() { return new Date(); }