remove rfdc, in favor of lodash deepcopy.

This commit is contained in:
Dan 2021-08-09 16:26:10 -04:00
parent a2ba129828
commit 1ee62ef57f
5 changed files with 17 additions and 17 deletions

View File

@ -6,10 +6,10 @@ import {MatInputModule} from '@angular/material/input';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {FormlyModule} from '@ngx-formly/core';
import {FormlyMaterialModule} from '@ngx-formly/material';
import createClone from 'rfdc';
import {FileType} from 'sartography-workflow-lib';
import {FileMetaDialogData} from '../../_interfaces/dialog-data';
import {FileMetaDialogComponent} from './file-meta-dialog.component';
import * as cloneDeep from "lodash/cloneDeep";
describe('EditFileMetaDialogComponent', () => {
let component: FileMetaDialogComponent;
@ -86,7 +86,7 @@ describe('EditFileMetaDialogComponent', () => {
component.model = dataBefore;
component.onSubmit();
const expectedData: FileMetaDialogData = createClone()(dataBefore);
const expectedData: FileMetaDialogData = cloneDeep(dataBefore);
expectedData.fileName = 'green_eggs.v1-2020-01-01.XML.bpmn';
expect(closeSpy).toHaveBeenCalledWith(expectedData);
});

View File

@ -9,7 +9,7 @@ import {MatSnackBarModule} from '@angular/material/snack-bar';
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {RouterTestingModule} from '@angular/router/testing';
import createClone from 'rfdc';
import * as cloneDeep from "lodash/cloneDeep";
import {of} from 'rxjs';
import {
ApiService,
@ -147,7 +147,7 @@ describe('FileListComponent', () => {
expect(routerNavigateSpy).toHaveBeenCalledWith([`/modeler/${mockWorkflowSpec0.id}/${mockFileMeta0.id}`]);
routerNavigateSpy.calls.reset();
const mockDmnMeta = createClone()(mockFileMeta0);
const mockDmnMeta = cloneDeep(mockFileMeta0);
mockDmnMeta.type = FileType.DMN;
component.editFile(mockDmnMeta);
expect(routerNavigateSpy).toHaveBeenCalledWith([`/modeler/${mockWorkflowSpec0.id}/${mockDmnMeta.id}`]);
@ -157,7 +157,7 @@ describe('FileListComponent', () => {
const routerNavigateSpy = spyOn((component as any).router, 'navigate');
const editFileMetaSpy = spyOn(component, 'editFileMeta');
component.workflowSpec = mockWorkflowSpec0;
const mockDocMeta = createClone()(mockFileMeta0);
const mockDocMeta = cloneDeep(mockFileMeta0);
mockDocMeta.type = FileType.DOCX;
component.editFile(mockDocMeta);
expect(routerNavigateSpy).not.toHaveBeenCalled();
@ -173,7 +173,7 @@ describe('FileListComponent', () => {
it('should open file metadata dialog', () => {
const _openFileDialogSpy = spyOn((component as any), '_openFileDialog').and.stub();
component.workflowSpec = mockWorkflowSpec0;
const mockDocMeta: FileMeta = createClone()(mockFileMeta0);
const mockDocMeta: FileMeta = cloneDeep(mockFileMeta0);
mockDocMeta.type = FileType.DOCX;
component.editFileMeta(mockDocMeta);

View File

@ -10,7 +10,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {Router} from '@angular/router';
import {RouterTestingModule} from '@angular/router/testing';
import * as FileSaver from 'file-saver';
import createClone from 'rfdc';
import * as cloneDeep from "lodash/cloneDeep";
import {of} from 'rxjs';
import {ApiService, FileMeta, FileType, MockEnvironment, mockFileMetaReference0, mockFileReference0} from 'sartography-workflow-lib';
import {OpenFileDialogComponent} from '../_dialogs/open-file-dialog/open-file-dialog.component';
@ -23,7 +23,7 @@ describe('ReferenceFilesComponent', () => {
const mockRouter = {navigate: jasmine.createSpy('navigate')};
// Mock file and response headers
const mockDocMeta: FileMeta = createClone()(mockFileMetaReference0);
const mockDocMeta: FileMeta = cloneDeep(mockFileMetaReference0);
mockDocMeta.type = FileType.XLSX;
const timeString = '2020-01-23T12:34:12.345Z';

View File

@ -10,8 +10,8 @@ import {MatSnackBarModule} from '@angular/material/snack-bar';
import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {RouterTestingModule} from '@angular/router/testing';
import createClone from 'rfdc';
import {Observable, of} from 'rxjs';
import * as cloneDeep from "lodash/cloneDeep";
import {of} from 'rxjs';
import {
ApiErrorsComponent,
ApiService,
@ -172,7 +172,7 @@ describe('WorkflowSpecListComponent', () => {
_updateWorkflowSpecSpy.calls.reset();
component.selectedSpec = mockWorkflowSpec0;
const modifiedData: WorkflowSpec = createClone({circles: true})(mockWorkflowSpec0);
const modifiedData: WorkflowSpec = cloneDeep(mockWorkflowSpec0);
modifiedData.display_name = 'Modified';
(component as any)._upsertWorkflowSpecification(false, modifiedData);
expect(_addWorkflowSpecSpy).not.toHaveBeenCalled();
@ -268,7 +268,7 @@ describe('WorkflowSpecListComponent', () => {
_updateWorkflowSpecCategorySpy.calls.reset();
component.selectedCat = mockWorkflowSpecCategory0;
const modifiedData: WorkflowSpecCategoryDialogData = createClone({circles: true})(mockWorkflowSpecCategory0);
const modifiedData: WorkflowSpecCategoryDialogData = cloneDeep(mockWorkflowSpecCategory0);
modifiedData.display_name = 'Modified';
(component as any)._upsertWorkflowSpecCategory(modifiedData);
expect(_addWorkflowSpecCategorySpy).not.toHaveBeenCalled();
@ -483,7 +483,7 @@ describe('WorkflowSpecListComponent', () => {
category_id: null,
};
(component as any)._loadWorkflowSpecs();
const allSpecs = createClone({circles: true})(mockWorkflowSpecs);
const allSpecs = cloneDeep(mockWorkflowSpecs);
allSpecs.push(mockMasterSpec);
const req = httpMock.expectOne(`apiRoot/workflow-specification`);

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { MatBottomSheet } from '@angular/material/bottom-sheet';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import createClone from 'rfdc';
import * as cloneDeep from "lodash/cloneDeep";
import {
ApiService,
isNumberDefined,
@ -352,7 +352,7 @@ export class WorkflowSpecListComponent implements OnInit {
id: number | string, direction: number,
list: Array<WorkflowSpecCategoryGroup | WorkflowSpec>
): Array<WorkflowSpecCategoryGroup | WorkflowSpec> {
const listClone = createClone({ circles: true })(list);
const listClone = cloneDeep(list);
const reorderedList = listClone.filter(item => item.id !== null && item.id !== undefined);
const i = reorderedList.findIndex(spec => spec.id === id);
if (i !== -1) {
@ -373,7 +373,7 @@ export class WorkflowSpecListComponent implements OnInit {
let numUpdated = 0;
cats.forEach((cat, j) => {
if (isNumberDefined(cat.id)) {
const newCat: WorkflowSpecCategoryGroup = createClone({ circles: true })(cat);
const newCat: WorkflowSpecCategoryGroup = cloneDeep(cat);
delete newCat.workflow_specs;
newCat.display_order = j;
@ -395,7 +395,7 @@ export class WorkflowSpecListComponent implements OnInit {
}
let numUpdated = 0;
specs.forEach((spec, j) => {
const newSpec = createClone({ circles: true })(spec);
const newSpec = cloneDeep(spec);
newSpec.display_order = j;
this.api.updateWorkflowSpecification(newSpec.id, newSpec).subscribe(() => {
numUpdated++;