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();
});
it('should create', () => {
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 {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 {MatIconModule} from '@angular/material/icon';
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 {ApiService, MockEnvironment, mockWorkflowSpecCategory0} from 'sartography-workflow-lib';
import {mockWorkflowSpecCategory0} from 'sartography-workflow-lib';
import {WorkflowSpecCategoryDialogData} from '../../_interfaces/dialog-data';
import {WorkflowSpecCategoryDialogComponent} from './workflow-spec-category-dialog.component';
describe('WorkflowSpecDialogComponent', () => {
let httpMock: HttpTestingController;
describe('WorkflowSpecCategoryDialogComponent', () => {
let component: WorkflowSpecCategoryDialogComponent;
let fixture: ComponentFixture<WorkflowSpecCategoryDialogComponent>;
@ -24,7 +22,6 @@ describe('WorkflowSpecDialogComponent', () => {
FormlyModule.forRoot(),
FormlyMaterialModule,
FormsModule,
HttpClientTestingModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
@ -34,8 +31,6 @@ describe('WorkflowSpecDialogComponent', () => {
],
declarations: [WorkflowSpecCategoryDialogComponent],
providers: [
ApiService,
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
{
provide: MatDialogRef,
useValue: {
@ -43,6 +38,13 @@ describe('WorkflowSpecDialogComponent', () => {
}
}
},
{
provide: MatDialog,
useValue: {
close: (dialogResult: any) => {
}
}
},
{provide: MAT_DIALOG_DATA, useValue: []},
]
})
@ -50,17 +52,11 @@ describe('WorkflowSpecDialogComponent', () => {
}));
beforeEach(() => {
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(WorkflowSpecCategoryDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
afterEach(() => {
httpMock.verify();
fixture.destroy();
});
it('should create', () => {
expect(component).toBeTruthy();
});

View File

@ -2,7 +2,6 @@ import {Component, Inject} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core';
import {v4 as uuidv4} from 'uuid';
import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data';
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 {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 {MatIconModule} from '@angular/material/icon';
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 {mockWorkflowSpec0} from 'sartography-workflow-lib';
import {ApiService, MockEnvironment, mockWorkflowSpec0, mockWorkflowSpecCategories} from 'sartography-workflow-lib';
import {WorkflowSpecDialogData} from '../../_interfaces/dialog-data';
import { WorkflowSpecDialogComponent } from './workflow-spec-dialog.component';
describe('WorkflowSpecDialogComponent', () => {
let httpMock: HttpTestingController;
let component: WorkflowSpecDialogComponent;
let fixture: ComponentFixture<WorkflowSpecDialogComponent>;
@ -23,6 +25,7 @@ describe('WorkflowSpecDialogComponent', () => {
FormlyModule.forRoot(),
FormlyMaterialModule,
FormsModule,
HttpClientTestingModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
@ -32,6 +35,8 @@ describe('WorkflowSpecDialogComponent', () => {
],
declarations: [ WorkflowSpecDialogComponent ],
providers: [
ApiService,
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
{
provide: MatDialogRef,
useValue: {
@ -39,6 +44,13 @@ describe('WorkflowSpecDialogComponent', () => {
}
}
},
{
provide: MatDialog,
useValue: {
close: (dialogResult: any) => {
}
}
},
{provide: MAT_DIALOG_DATA, useValue: []},
]
})
@ -46,9 +58,20 @@ describe('WorkflowSpecDialogComponent', () => {
}));
beforeEach(() => {
httpMock = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(WorkflowSpecDialogComponent);
component = fixture.componentInstance;
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', () => {