mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-5857] added unit tests for formatLabel
This commit is contained in:
@@ -331,4 +331,20 @@ describe('DateTimeWidgetComponent', () => {
|
||||
expect(adfLeftLabel).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('format label', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
name: 'Date Time',
|
||||
dateDisplayFormat: 'd-M-yyyy hh:mm a'
|
||||
});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should format label correctly', () => {
|
||||
const result = widget.formatLabel(widget.field);
|
||||
|
||||
expect(result).toBe('Date Time (D-M-YYYY hh:mm A)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ import { WidgetComponent } from '../widget.component';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { DateFnsUtils } from '../../../../common';
|
||||
import { TranslationService } from '../../../../../../../core/src/lib/translation/translation.service';
|
||||
import { TranslationService } from '../../../../../../../core/src/lib/translation';
|
||||
import { FormFieldModel } from '../core';
|
||||
import { isValid } from 'date-fns';
|
||||
import { DateFnsAdapter } from '@angular/material-date-fns-adapter';
|
||||
|
||||
@@ -259,4 +259,20 @@ describe('DateWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(dateElement.value).toContain('03-02-2020');
|
||||
});
|
||||
|
||||
describe('format label', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
name: 'Date',
|
||||
dateDisplayFormat: 'd-M-yyyy'
|
||||
});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should format label correctly', () => {
|
||||
const result = widget.formatLabel(widget.field);
|
||||
|
||||
expect(result).toBe('Date (D-M-YYYY)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns
|
||||
import { DateFnsUtils } from '../../../../common';
|
||||
import { isValid } from 'date-fns';
|
||||
import { FormFieldModel } from '../core';
|
||||
import { TranslationService } from '../../../../../../../core/src/lib/translation/translation.service';
|
||||
import { TranslationService } from '../../../../../../../core/src/lib/translation';
|
||||
|
||||
@Component({
|
||||
selector: 'date-widget',
|
||||
|
||||
+16
@@ -541,4 +541,20 @@ describe('DateWidgetComponent', () => {
|
||||
expect(element.querySelector('.adf-invalid')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('format label', () => {
|
||||
beforeEach(() => {
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: '<id>' }), {
|
||||
name: 'Date Field',
|
||||
dateDisplayFormat: 'd-M-yyyy'
|
||||
});
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should format label correctly', () => {
|
||||
const result = widget.formatLabel(widget.field);
|
||||
|
||||
expect(result).toBe('Date Field (D-M-YYYY)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user