Fixes broken tests, build warnings, and deprecated TestBed.get errors

This commit is contained in:
Aaron Louie 2020-02-25 15:03:22 -05:00
parent a3b3a69096
commit cc4fe0df86
10 changed files with 28 additions and 12 deletions

View File

@ -54,7 +54,7 @@ describe('OpenFileDialogComponent', () => {
}));
beforeEach(() => {
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(OpenFileDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@ -3,6 +3,7 @@ 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';
@ -24,7 +25,10 @@ describe('AppComponent', () => {
MatIconModule,
MatMenuModule,
RouterTestingModule,
]
],
providers: [
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
],
})
.compileComponents();
}));

View File

@ -30,7 +30,7 @@ describe('DiagramComponent', () => {
]
});
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.debugElement.componentInstance;
component.fileName = '';

View File

@ -67,7 +67,7 @@ describe('FileListComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(FileListComponent);
component = fixture.componentInstance;
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
component.workflowSpec = mockWorkflowSpec0;
fixture.detectChanges();

View File

@ -101,7 +101,7 @@ describe('ModelerComponent', () => {
}
})
.compileComponents();
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(ModelerComponent);
component = fixture.debugElement.componentInstance;
component.diagramComponent = TestBed.createComponent(DiagramComponent).componentInstance;
@ -238,8 +238,9 @@ describe('ModelerComponent', () => {
});
it('should update the diagram file on change', () => {
const initialValue = component.diagramComponent.value;
expect(initialValue).toBeTruthy();
const valBefore = '';
component.diagramComponent.writeValue(valBefore);
expect(component.diagramComponent.value).toEqual(valBefore);
const newValue = '<xml>newExpectedValue</xml>';
component.diagramComponent.writeValue(newValue);
@ -249,6 +250,10 @@ 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();

View File

@ -39,7 +39,7 @@ describe('NavbarComponent', () => {
beforeEach(() => {
localStorage.setItem('token', 'some_token');
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(NavbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@ -58,7 +58,7 @@ describe('SignInComponent', () => {
}));
beforeEach(() => {
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(SignInComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@ -26,7 +26,7 @@ describe('SignOutComponent', () => {
}));
beforeEach(() => {
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(SignOutComponent);
component = fixture.componentInstance;
fixture.detectChanges();

View File

@ -71,7 +71,7 @@ describe('WorkflowSpecListComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(WorkflowSpecListComponent);
component = fixture.componentInstance;
httpMock = TestBed.get(HttpTestingController);
httpMock = TestBed.inject(HttpTestingController);
fixture.detectChanges();
const sReq = httpMock.expectOne('apiRoot/workflow-specification');

View File

@ -22,5 +22,12 @@
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
}
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}