diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index a507e95..6ed4289 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,13 +1,24 @@ +import {Component} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {MatIconModule} from '@angular/material/icon'; -import {MatMenuModule} from '@angular/material/menu'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {RouterTestingModule} from '@angular/router/testing'; import {MockEnvironment} from 'sartography-workflow-lib'; - import {AppComponent} from './app.component'; -import {FooterComponent} from './footer/footer.component'; -import {NavbarComponent} from './navbar/navbar.component'; + + +@Component({ + selector: 'app-navbar', + template: '' +}) +class MockNavbarComponent { +} + +@Component({ + selector: 'app-footer', + template: '' +}) +class MockFooterComponent { +} describe('AppComponent', () => { let component: AppComponent; @@ -17,13 +28,11 @@ describe('AppComponent', () => { TestBed.configureTestingModule({ declarations: [ AppComponent, - FooterComponent, - NavbarComponent + MockNavbarComponent, + MockFooterComponent ], imports: [ BrowserAnimationsModule, - MatIconModule, - MatMenuModule, RouterTestingModule, ], providers: [ diff --git a/src/app/modeler/modeler.component.spec.ts b/src/app/modeler/modeler.component.spec.ts index f5b1d25..2044e59 100644 --- a/src/app/modeler/modeler.component.spec.ts +++ b/src/app/modeler/modeler.component.spec.ts @@ -238,11 +238,11 @@ describe('ModelerComponent', () => { }); it('should update the diagram file on change', () => { - const valBefore = ''; + const valBefore = BPMN_DIAGRAM.replace('REPLACE_ME', 'raindrops_on_roses'); component.diagramComponent.writeValue(valBefore); expect(component.diagramComponent.value).toEqual(valBefore); - const newValue = 'newExpectedValue'; + const newValue = BPMN_DIAGRAM.replace('REPLACE_ME', 'whiskers_on_kittens'); component.diagramComponent.writeValue(newValue); expect(component.diagramComponent.value).toEqual(newValue); @@ -250,16 +250,12 @@ describe('ModelerComponent', () => { }); it('should save file changes when existing diagram is modified and then saved', () => { - const valBefore = ''; - component.diagramComponent.writeValue(valBefore); - expect(component.diagramComponent.value).toEqual(valBefore); - const saveFileChangesSpy = spyOn(component, 'saveFileChanges').and.stub(); const editFileMetaSpy = spyOn(component, 'editFileMeta').and.stub(); component.workflowSpec = mockWorkflowSpec0; component.diagramFileMeta = mockFileMeta0; - component.diagramComponent.writeValue('newValue'); + component.diagramComponent.writeValue(BPMN_DIAGRAM.replace('REPLACE_ME', 'bright_copper_kettles')); component.saveChanges(); expect(saveFileChangesSpy).toHaveBeenCalled(); @@ -273,7 +269,7 @@ describe('ModelerComponent', () => { component.newDiagram(FileType.BPMN); expect(component.diagramFileMeta).toBeFalsy(); - component.diagramComponent.writeValue('newValue'); + component.diagramComponent.writeValue(BPMN_DIAGRAM.replace('REPLACE_ME', 'warm_woolen_mittens')); component.saveChanges(); expect(saveFileChangesSpy).not.toHaveBeenCalled(); @@ -287,7 +283,7 @@ describe('ModelerComponent', () => { component.workflowSpec = mockWorkflowSpec0; component.diagramFileMeta = mockFileMeta0; - component.diagramComponent.writeValue('newValue'); + component.diagramComponent.writeValue(BPMN_DIAGRAM.replace('REPLACE_ME', 'brown_paper_packages_tied_up_with_strings')); component.saveFileChanges(); expect(updateFileMetaSpy).toHaveBeenCalledWith(mockFileMeta0); @@ -310,7 +306,7 @@ describe('ModelerComponent', () => { }); it('should update file metadata for existing file', () => { - const newXml = 'New Value'; + const newXml = BPMN_DIAGRAM.replace('REPLACE_ME', 'cream_colored_ponies'); const data: FileMetaDialogData = { fileName: mockFileMeta0.name, fileType: FileType.BPMN, @@ -340,7 +336,7 @@ describe('ModelerComponent', () => { }); it('should create new file metadata for new file', () => { - const newXml = 'New Value'; + const newXml = BPMN_DIAGRAM.replace('REPLACE_ME', 'crisp_apple_strudels'); const data: FileMetaDialogData = { fileName: mockFileMeta0.name, fileType: FileType.BPMN, @@ -404,8 +400,8 @@ describe('ModelerComponent', () => { }); it('should start a new diagram', () => { - component.xml = 'old value'; - component.draftXml = 'even older value'; + component.xml = BPMN_DIAGRAM.replace('REPLACE_ME', 'doorbells'); + component.draftXml = BPMN_DIAGRAM.replace('REPLACE_ME', 'sleigh_bells'); component.diagramFileMeta = mockFileMeta0; component.diagramFile = mockFileMeta0.file; component.workflowSpec = mockWorkflowSpec0; diff --git a/src/app/navbar/navbar.component.spec.ts b/src/app/navbar/navbar.component.spec.ts index 7d0a49e..0a3b679 100644 --- a/src/app/navbar/navbar.component.spec.ts +++ b/src/app/navbar/navbar.component.spec.ts @@ -5,9 +5,9 @@ import {MatMenuModule} from '@angular/material/menu'; import {Router} from '@angular/router'; import {RouterTestingModule} from '@angular/router/testing'; import {ApiService, MockEnvironment, mockUser} from 'sartography-workflow-lib'; - import { NavbarComponent } from './navbar.component'; + describe('NavbarComponent', () => { let component: NavbarComponent; let fixture: ComponentFixture;