blob: a532087908101c0874f88da1cb91681fe30a297a [file] [log] [blame]
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatDialogHarness } from '@angular/material/dialog/testing';
import { OverlayContainer } from '@angular/cdk/overlay';
import { EditTypeDialogComponent } from './edit-type-dialog.component';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { editPlatformTypeDialogData } from '../../types/editPlatformTypeDialogData';
import { editPlatformTypeDialogDataMode } from '../../types/EditPlatformTypeDialogDataMode.enum';
let loader: HarnessLoader;
describe('EditTypeDialogComponent', () => {
let component: EditTypeDialogComponent;
let fixture: ComponentFixture<EditTypeDialogComponent>;
let overlayContainer: OverlayContainer;
let matDialogData: editPlatformTypeDialogData = {
mode: editPlatformTypeDialogDataMode.edit,
type: {
interfaceLogicalType: 'boolean',
interfacePlatform2sComplement: false,
interfacePlatformTypeAnalogAccuracy: 'N/A',
interfacePlatformTypeBitsResolution: 'N/A',
interfacePlatformTypeCompRate: '50Hz',
interfacePlatformTypeBitSize: '8',
interfacePlatformTypeDefaultValue: '0',
interfacePlatformTypeEnumLiteral: '',
interfacePlatformTypeMinval: '0',
interfacePlatformTypeMsbValue: '0',
interfacePlatformTypeMaxval: '1',
interfacePlatformTypeUnits: 'N/A',
interfacePlatformTypeValidRangeDescription: '',
name:'FACE Boolean'
}
}
beforeEach(async () => {
await TestBed.configureTestingModule({
imports:[MatDialogModule, MatFormFieldModule,MatInputModule,NoopAnimationsModule,FormsModule,MatSlideToggleModule],
declarations: [EditTypeDialogComponent],
providers: [
{ provide: MatDialogRef, useValue: {} },
{
provide: MAT_DIALOG_DATA, useValue: matDialogData}
]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(EditTypeDialogComponent);
loader = TestbedHarnessEnvironment.loader(fixture);
overlayContainer = TestBed.inject(OverlayContainer);
component = fixture.componentInstance;
fixture.detectChanges();
});
afterEach(async () => {
const dialogs = loader.getAllHarnesses(MatDialogHarness);
await Promise.all((await dialogs).map(async (d: MatDialogHarness) => await d.close()));
overlayContainer.ngOnDestroy();
})
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', async () => {
const dialogs = await loader.getAllHarnesses(MatDialogHarness);
dialogs.forEach((x) => {
console.log("Dialog: ")
console.log(x.getAriaLabel());
})
//const header = await dialog.getChildLoader('.mat-dialog-title');
//console.log(header);
expect(component).toBeTruthy();
});
});