Fixes failing tests

This commit is contained in:
Aaron Louie 2020-03-18 13:33:00 -04:00
parent d4d43537d6
commit d4ef749b1c
4 changed files with 35 additions and 18 deletions

View File

@ -65,7 +65,6 @@ describe('OpenFileDialogComponent', () => {
fixture.destroy(); fixture.destroy();
}); });
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });

View File

@ -1,19 +1,17 @@
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog';
import {MatFormFieldModule} from '@angular/material/form-field'; import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon'; import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input'; import {MatInputModule} from '@angular/material/input';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {FormlyModule} from '@ngx-formly/core'; import {FormlyModule} from '@ngx-formly/core';
import {FormlyMaterialModule} from '@ngx-formly/material'; import {FormlyMaterialModule} from '@ngx-formly/material';
import {ApiService, MockEnvironment, mockWorkflowSpecCategory0} from 'sartography-workflow-lib'; import {mockWorkflowSpecCategory0} from 'sartography-workflow-lib';
import {WorkflowSpecCategoryDialogData} from '../../_interfaces/dialog-data'; import {WorkflowSpecCategoryDialogData} from '../../_interfaces/dialog-data';
import {WorkflowSpecCategoryDialogComponent} from './workflow-spec-category-dialog.component'; import {WorkflowSpecCategoryDialogComponent} from './workflow-spec-category-dialog.component';
describe('WorkflowSpecDialogComponent', () => { describe('WorkflowSpecCategoryDialogComponent', () => {
let httpMock: HttpTestingController;
let component: WorkflowSpecCategoryDialogComponent; let component: WorkflowSpecCategoryDialogComponent;
let fixture: ComponentFixture<WorkflowSpecCategoryDialogComponent>; let fixture: ComponentFixture<WorkflowSpecCategoryDialogComponent>;
@ -24,7 +22,6 @@ describe('WorkflowSpecDialogComponent', () => {
FormlyModule.forRoot(), FormlyModule.forRoot(),
FormlyMaterialModule, FormlyMaterialModule,
FormsModule, FormsModule,
HttpClientTestingModule,
MatDialogModule, MatDialogModule,
MatFormFieldModule, MatFormFieldModule,
MatIconModule, MatIconModule,
@ -34,8 +31,6 @@ describe('WorkflowSpecDialogComponent', () => {
], ],
declarations: [WorkflowSpecCategoryDialogComponent], declarations: [WorkflowSpecCategoryDialogComponent],
providers: [ providers: [
ApiService,
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
{ {
provide: MatDialogRef, provide: MatDialogRef,
useValue: { useValue: {
@ -43,6 +38,13 @@ describe('WorkflowSpecDialogComponent', () => {
} }
} }
}, },
{
provide: MatDialog,
useValue: {
close: (dialogResult: any) => {
}
}
},
{provide: MAT_DIALOG_DATA, useValue: []}, {provide: MAT_DIALOG_DATA, useValue: []},
] ]
}) })
@ -50,17 +52,11 @@ describe('WorkflowSpecDialogComponent', () => {
})); }));
beforeEach(() => { beforeEach(() => {
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(WorkflowSpecCategoryDialogComponent); fixture = TestBed.createComponent(WorkflowSpecCategoryDialogComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
afterEach(() => {
httpMock.verify();
fixture.destroy();
});
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });

View File

@ -2,7 +2,6 @@ import {Component, Inject} from '@angular/core';
import {FormGroup} from '@angular/forms'; import {FormGroup} from '@angular/forms';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core'; import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core';
import {v4 as uuidv4} from 'uuid';
import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data'; import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data';
import {toSnakeCase} from '../../_util/string-clean'; import {toSnakeCase} from '../../_util/string-clean';

View File

@ -1,18 +1,20 @@
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from '@angular/material/dialog';
import {MatFormFieldModule} from '@angular/material/form-field'; import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon'; import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input'; import {MatInputModule} from '@angular/material/input';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {FormlyModule} from '@ngx-formly/core'; import {FormlyModule} from '@ngx-formly/core';
import {FormlyMaterialModule} from '@ngx-formly/material'; import {FormlyMaterialModule} from '@ngx-formly/material';
import {mockWorkflowSpec0} from 'sartography-workflow-lib'; import {ApiService, MockEnvironment, mockWorkflowSpec0, mockWorkflowSpecCategories} from 'sartography-workflow-lib';
import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data'; import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data';
import { WorkflowSpecDialogComponent } from './workflow-spec-dialog.component'; import { WorkflowSpecDialogComponent } from './workflow-spec-dialog.component';
describe('WorkflowSpecDialogComponent', () => { describe('WorkflowSpecDialogComponent', () => {
let httpMock: HttpTestingController;
let component: WorkflowSpecDialogComponent; let component: WorkflowSpecDialogComponent;
let fixture: ComponentFixture<WorkflowSpecDialogComponent>; let fixture: ComponentFixture<WorkflowSpecDialogComponent>;
@ -23,6 +25,7 @@ describe('WorkflowSpecDialogComponent', () => {
FormlyModule.forRoot(), FormlyModule.forRoot(),
FormlyMaterialModule, FormlyMaterialModule,
FormsModule, FormsModule,
HttpClientTestingModule,
MatDialogModule, MatDialogModule,
MatFormFieldModule, MatFormFieldModule,
MatIconModule, MatIconModule,
@ -32,6 +35,8 @@ describe('WorkflowSpecDialogComponent', () => {
], ],
declarations: [ WorkflowSpecDialogComponent ], declarations: [ WorkflowSpecDialogComponent ],
providers: [ providers: [
ApiService,
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
{ {
provide: MatDialogRef, provide: MatDialogRef,
useValue: { useValue: {
@ -39,6 +44,13 @@ describe('WorkflowSpecDialogComponent', () => {
} }
} }
}, },
{
provide: MatDialog,
useValue: {
close: (dialogResult: any) => {
}
}
},
{provide: MAT_DIALOG_DATA, useValue: []}, {provide: MAT_DIALOG_DATA, useValue: []},
] ]
}) })
@ -46,9 +58,20 @@ describe('WorkflowSpecDialogComponent', () => {
})); }));
beforeEach(() => { beforeEach(() => {
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(WorkflowSpecDialogComponent); fixture = TestBed.createComponent(WorkflowSpecDialogComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
const catReq = httpMock.expectOne('apiRoot/workflow-specification-category');
expect(catReq.request.method).toEqual('GET');
catReq.flush(mockWorkflowSpecCategories);
expect(component.categories.length).toBeGreaterThan(0);
});
afterEach(() => {
httpMock.verify();
fixture.destroy();
}); });
it('should create', () => { it('should create', () => {