mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ACS-5861] Replace moment to date-fns in process-name.pipe.ts (#8831)
This commit is contained in:
parent
837b3b1b92
commit
b77691bb08
@ -18,7 +18,6 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { ProcessNamePipe } from './process-name.pipe';
|
import { ProcessNamePipe } from './process-name.pipe';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import moment from 'moment';
|
|
||||||
import { LocalizedDatePipe, CoreTestingModule } from '@alfresco/adf-core';
|
import { LocalizedDatePipe, CoreTestingModule } from '@alfresco/adf-core';
|
||||||
import { ProcessInstance } from '../process-list';
|
import { ProcessInstance } from '../process-list';
|
||||||
|
|
||||||
@ -57,13 +56,13 @@ describe('ProcessNamePipe', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add the current datetime to the process name', () => {
|
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);
|
const transformResult = processNamePipe.transform(nameWithDatetimeIdentifier);
|
||||||
expect(transformResult).toEqual(`${defaultName} - ${mockLocalizedCurrentDate}`);
|
expect(transformResult).toEqual(`${defaultName} - ${mockLocalizedCurrentDate}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add the current datetime and the selected process definition name when both identifiers are present', () => {
|
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);
|
const transformResult = processNamePipe.transform(nameWithAllIdentifiers, fakeProcessInstanceDetails);
|
||||||
expect(transformResult).toEqual(`${defaultName} ${fakeProcessInstanceDetails.processDefinitionName} - ${mockLocalizedCurrentDate}`);
|
expect(transformResult).toEqual(`${defaultName} ${fakeProcessInstanceDetails.processDefinitionName} - ${mockLocalizedCurrentDate}`);
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Pipe, PipeTransform } from '@angular/core';
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
import moment from 'moment';
|
import { getTime } from 'date-fns';
|
||||||
import { LocalizedDatePipe } from '@alfresco/adf-core';
|
import { LocalizedDatePipe } from '@alfresco/adf-core';
|
||||||
import { ProcessInstance } from '../process-list';
|
import { ProcessInstance } from '../process-list';
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ export class ProcessNamePipe implements PipeTransform {
|
|||||||
transform(processNameFormat: string, processInstance?: ProcessInstance): string {
|
transform(processNameFormat: string, processInstance?: ProcessInstance): string {
|
||||||
let processName = processNameFormat;
|
let processName = processNameFormat;
|
||||||
if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
|
if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
|
||||||
const presentDateTime = moment.now();
|
const presentDateTime = getTime(new Date());
|
||||||
processName = processName.replace(
|
processName = processName.replace(
|
||||||
DATE_TIME_IDENTIFIER_REG_EXP,
|
DATE_TIME_IDENTIFIER_REG_EXP,
|
||||||
this.localizedDatePipe.transform(presentDateTime, 'medium')
|
this.localizedDatePipe.transform(presentDateTime, 'medium')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user