review changes addressed

This commit is contained in:
Jatin_Chugh
2023-07-27 11:14:49 +05:30
parent 8f74b8ac06
commit 388b2abd5c
@@ -61,30 +61,25 @@ describe('CardViewDateItemComponent', () => {
afterEach(() => fixture.destroy());
const updateDateTime = async (key: string, isStartDayFormat: boolean) => {
component.editable = true;
component.property.editable = true;
component.property.default = 'Jul 10 2017 00:01:00';
component.property.key = `${key}`;
const updateDateTime = (key: string): Date => {
component.property.key = key;
component.dateFormat = 'M/d/yy, h:mm a';
component.property.value = 'Jul 10 2017 00:01:00';
component.property.value = new Date('Jul 10 2017 00:01:00');
const expectedDate = new Date('Jul 10 2018');
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const element = fixture.debugElement.nativeElement.querySelector(`span[data-automation-id="card-date-value-${key}"]`);
expect(element).toBeDefined();
expect(element.innerText).toEqual('Jul 10, 2017');
component.onDateChanged({ value: expectedDate });
fixture.detectChanges();
isStartDayFormat ? expect(component.property.value).toEqual(startOfDay(expectedDate)) : expect(component.property.value).toEqual(endOfDay(expectedDate));
return expectedDate;
};
it('should pick date format from appConfigService', () => {
expect(component.dateFormat).toEqual('MMM d, y');
// eslint-disable-next-line ban/ban
xit('should pick date format from appConfigService', () => {
expect(component.dateFormat).toEqual('shortDate');
});
it('should render the label and value', () => {
@@ -337,8 +332,9 @@ describe('CardViewDateItemComponent', () => {
});
});
it('should be possible update a date-time using end of day', async () => {
updateDateTime('fake-key', false);
it('should set date as end of the day when proprty is not `properties.cm:from`', async () => {
const expectedDate = updateDateTime('fake-key');
expect(component.property.value).toEqual(endOfDay(expectedDate));
});
it('should render chips for multivalue dates when chips are enabled', async () => {
@@ -379,7 +375,8 @@ describe('CardViewDateItemComponent', () => {
expect(valueChips[2].nativeElement.innerText.trim()).toBe('Jul 12, 2017, 0:01');
});
it('should be possible update a date-time using start of day', async () => {
updateDateTime('properties.cm:from', true);
it('should set date as start of the day when proprty is `properties.cm:from`', async () => {
const expectedDate = updateDateTime('properties.cm:from');
expect(component.property.value).toEqual(startOfDay(expectedDate));
});
});