Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-5861] Replace moment to date-fns in process-name.pipe.ts #8831

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { TestBed } from '@angular/core/testing';
import { ProcessNamePipe } from './process-name.pipe';
import { TranslateModule } from '@ngx-translate/core';
import moment from 'moment';
import { LocalizedDatePipe, CoreTestingModule } from '@alfresco/adf-core';
import { ProcessInstance } from '../process-list';

Expand Down Expand Up @@ -57,13 +56,13 @@ describe('ProcessNamePipe', () => {
});

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}`);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/process-services/src/lib/pipes/process-name.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Pipe, PipeTransform } from '@angular/core';
import moment from 'moment';
import { getTime } from 'date-fns';
import { LocalizedDatePipe } from '@alfresco/adf-core';
import { ProcessInstance } from '../process-list';

Expand All @@ -31,7 +31,7 @@ export class ProcessNamePipe implements PipeTransform {
transform(processNameFormat: string, processInstance?: ProcessInstance): 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')
Expand Down
Loading