Skip to content

Commit

Permalink
review changes addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
jatin2008 committed Jul 21, 2023
1 parent 3878377 commit ae00544
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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));
});
});

0 comments on commit ae00544

Please sign in to comment.