Ardit Domi fa587510bd
[AAE-9200] - Be able to customise task/process list and header date f… (#7711)
* [AAE-9200] - Be able to customise task/process list and header date formats

* Update json schema

* Revert schema changes

* Update task and process name translation values

* move task/process header date formats inside header config

* Add documentation

* Update documentation

* Use a fixed timezone for unit tests of core and cloud

* Fix e2e due to column rename

* More e2e fixes due to column rename, remove test covered by unit test
2022-07-19 15:46:31 +02:00

74 lines
2.9 KiB
TypeScript

/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { UserPreferencesService } from '../../../services';
import { AppConfigService } from '../../../app-config';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreTestingModule } from '../../../testing';
import { DateCellComponent } from './date-cell.component';
describe('DateCellComponent', () => {
let appConfigService: AppConfigService;
let userPreferencesService: UserPreferencesService;
let fixture: ComponentFixture<DateCellComponent>;
let component: DateCellComponent;
let getLocaleSpy: jasmine.Spy;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
CoreTestingModule
],
declarations: [DateCellComponent]
});
appConfigService = TestBed.inject(AppConfigService);
userPreferencesService = TestBed.inject(UserPreferencesService);
getLocaleSpy = spyOn(userPreferencesService, 'select').and.callThrough();
appConfigService.config = {
dateValues: {
defaultDateFormat: 'mediumDate',
defaultTooltipDateFormat: 'medium'
}
};
fixture = TestBed.createComponent(DateCellComponent);
component = fixture.componentInstance;
});
it('should read locale from user preferences service', () => {
expect(getLocaleSpy).toHaveBeenCalledWith('locale');
expect(component.currentLocale).toEqual('en');
});
it('should read date format values from app config service', () => {
expect(component.format).toEqual('mediumDate');
expect(component.tooltipDateFormat).toEqual('medium');
});
it('should date values be formatted based on the formats defined in the app config', () => {
component.value$.next('2022-07-14T11:50:45.973+0000');
component.tooltip = '2022-07-14T11:50:45.973+0000';
fixture.detectChanges();
const dateCellValue = fixture.nativeElement.querySelector('.adf-datatable-cell-value');
const tooltipValue = dateCellValue.attributes['title'].value;
expect(dateCellValue.textContent.trim()).toEqual('Jul 14, 2022');
expect(dateCellValue.attributes['aria-label'].value).toEqual('Jul 14, 2022');
expect(tooltipValue).toEqual('Jul 14, 2022, 11:50:45 AM');
});
});