mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-5860] Migration of process name cloud pipe from moment to date-fns (#8797)
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import moment from 'moment';
|
||||
import { ProcessNameCloudPipe } from './process-name-cloud.pipe';
|
||||
import { LocalizedDatePipe, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { ProcessInstanceCloud } from '../process/start-process/models/process-instance-cloud.model';
|
||||
@@ -57,13 +56,13 @@ describe('ProcessNameCloudPipe', () => {
|
||||
});
|
||||
|
||||
it('should add the current datetime to the process name', () => {
|
||||
spyOn(moment, 'now').and.returnValue(mockCurrentDate);
|
||||
spyOn(Date.prototype, 'getTime').and.returnValue(mockCurrentDate);
|
||||
const transformResult = processNamePipe.transform(nameWithDatetimeIdentifier);
|
||||
expect(transformResult).toEqual(`${defaultName} - ${mockLocalizedCurrentDate}`);
|
||||
});
|
||||
|
||||
it('should add the current datetime and the selected process definition name when both identifiers are present', () => {
|
||||
spyOn(moment, 'now').and.returnValue(mockCurrentDate);
|
||||
spyOn(Date.prototype, 'getTime').and.returnValue(mockCurrentDate);
|
||||
const transformResult = processNamePipe.transform(nameWithAllIdentifiers, fakeProcessInstanceDetails);
|
||||
expect(transformResult).toEqual(`${defaultName} ${fakeProcessInstanceDetails.processDefinitionName} - ${mockLocalizedCurrentDate}`);
|
||||
});
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import moment from 'moment';
|
||||
import { LocalizedDatePipe } from '@alfresco/adf-core';
|
||||
import { ProcessInstanceCloud } from '../process/start-process/models/process-instance-cloud.model';
|
||||
import { getTime } from 'date-fns';
|
||||
|
||||
export const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
|
||||
export const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
|
||||
@@ -31,7 +31,7 @@ export class ProcessNameCloudPipe implements PipeTransform {
|
||||
transform(processNameFormat: string, processInstance?: ProcessInstanceCloud): string {
|
||||
let processName = processNameFormat;
|
||||
if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
|
||||
const presentDateTime = moment.now();
|
||||
const presentDateTime = getTime(new Date());
|
||||
processName = processName.replace(
|
||||
DATE_TIME_IDENTIFIER_REG_EXP,
|
||||
this.localizedDatePipe.transform(presentDateTime, 'medium')
|
||||
|
Reference in New Issue
Block a user