mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
review changes addressed
This commit is contained in:
+13
-16
@@ -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));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user