From 011f0a735669fbf7221ae8261c20e5160419e3b7 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Fri, 13 Aug 2021 15:03:33 -0400 Subject: [PATCH] Removes extraneous method. --- src/app/diagram/diagram.component.spec.ts | 4 ++-- src/app/diagram/diagram.component.ts | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/app/diagram/diagram.component.spec.ts b/src/app/diagram/diagram.component.spec.ts index 07a0107..7c0b8af 100644 --- a/src/app/diagram/diagram.component.spec.ts +++ b/src/app/diagram/diagram.component.spec.ts @@ -28,13 +28,13 @@ describe('DiagramComponent', () => { const mockRouter = {navigate: jasmine.createSpy('navigate')}; const testSaveAs = async (fileType: FileType, xml: string, callMethod: string, filename: string) => { const saveDiagramSpy = spyOn(component, 'saveDiagram').and.callThrough(); - const _fileSaveAsSpy = spyOn((component as any), '_fileSaveAs').and.stub(); + const fileSaveAsSpy = spyOn(FileSaver, 'saveAs').and.stub(); component.fileName = filename + '.' + fileType; component.diagramType = fileType; component.xml = xml; await component[callMethod](); await expect(saveDiagramSpy).toHaveBeenCalled(); - await expect(_fileSaveAsSpy).toHaveBeenCalledWith(jasmine.any(Blob), jasmine.stringMatching(filename)); + await expect(fileSaveAsSpy).toHaveBeenCalledWith(jasmine.any(Blob), jasmine.stringMatching(filename)); }; beforeEach(waitForAsync(() => { diff --git a/src/app/diagram/diagram.component.ts b/src/app/diagram/diagram.component.ts index 288dd9c..481eb77 100644 --- a/src/app/diagram/diagram.component.ts +++ b/src/app/diagram/diagram.component.ts @@ -1,5 +1,4 @@ import { formatDate } from '@angular/common'; -import { HttpErrorResponse } from '@angular/common/http'; import { AfterViewInit, Component, @@ -43,7 +42,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On @Input() validation_data: { [key: string]: any } = {}; @Input() validation_state: string; @Output() validationStart: EventEmitter = new EventEmitter(); - @Output() private importDone: EventEmitter = new EventEmitter(); + @Output() importDone: EventEmitter = new EventEmitter(); public eventBus; private diagramType: FileType; private modeler: BpmnModeler | DmnModeler; @@ -170,7 +169,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On await this.saveDiagram(); const {svg} = await this.modeler.saveSVG(); const blob = new Blob([svg], {type: 'image/svg+xml'}); - this._fileSaveAs(blob, this.insertDateIntoFileName()); + fileSaver.saveAs(blob, this.insertDateIntoFileName()); } async saveDiagram() { @@ -186,9 +185,9 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On async saveXML() { await this.saveDiagram(); - const {xml} = await this.modeler.saveXML({format: true}) + const {xml} = await this.modeler.saveXML({format: true}); const blob = new Blob([xml], {type: 'text/xml'}); - this._fileSaveAs(blob, this.insertDateIntoFileName()); + fileSaver.saveAs(blob, this.insertDateIntoFileName()); } onImport(err?: Error | BpmnError, warnings?: BpmnWarning[]) { @@ -242,7 +241,7 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On const diagramType = getDiagramTypeFromXml(xml); this.openDiagram(xml, diagramType); }, - error => this._handleErrors(error) + error => this._handleErrors(error), ); } @@ -377,9 +376,4 @@ export class DiagramComponent implements ControlValueAccessor, AfterViewInit, On return `${this.fileName}_${dateString}.${this.diagramType}`; } } - - private _fileSaveAs(blob: Blob, filename: string) { - fileSaver.saveAs(blob, filename); - }; - }