From 1ee62ef57fd5fea5fef2d766deebd68198f7a06f Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 9 Aug 2021 16:26:10 -0400 Subject: [PATCH] remove rfdc, in favor of lodash deepcopy. --- .../file-meta-dialog.component.spec.ts | 4 ++-- src/app/file-list/file-list.component.spec.ts | 8 ++++---- .../reference-files/reference-files.component.spec.ts | 4 ++-- .../workflow-spec-list.component.spec.ts | 10 +++++----- .../workflow-spec-list/workflow-spec-list.component.ts | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.spec.ts b/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.spec.ts index 61de7b2..3dae9c9 100644 --- a/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.spec.ts +++ b/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.spec.ts @@ -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); }); diff --git a/src/app/file-list/file-list.component.spec.ts b/src/app/file-list/file-list.component.spec.ts index 608de31..8366bff 100644 --- a/src/app/file-list/file-list.component.spec.ts +++ b/src/app/file-list/file-list.component.spec.ts @@ -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); diff --git a/src/app/reference-files/reference-files.component.spec.ts b/src/app/reference-files/reference-files.component.spec.ts index 3ffaff1..b97cf15 100644 --- a/src/app/reference-files/reference-files.component.spec.ts +++ b/src/app/reference-files/reference-files.component.spec.ts @@ -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'; diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts index c6f5e48..568ab2f 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.spec.ts @@ -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`); diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.ts b/src/app/workflow-spec-list/workflow-spec-list.component.ts index d6e5feb..acbae39 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.ts @@ -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 ): Array { - 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++;