I have an angular app where I need to test a mat-dilaog by passing data. I am able to pass it through as below.
{ provide: MAT_DIALOG_DATA, useValue: staffData }
,
But I am trying to find a way to pass different values as part of staffData
for different tests. I am not finding a way to do it
let staffData: any = {
gridData: [],
type: "add",
adConfigured: false,
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [StaffAddComponent, HelpDialogComponent],
imports: [
FormsModule,
ReactiveFormsModule,
HttpClientTestingModule,
OverlayModule,
MatDialogModule,
],
providers: [
StaffaddService,
AuthService,
{ provide: MatDialogRef, useValue: {} },
{ provide: MAT_DIALOG_DATA, useValue: staffData },
{ provide: MatDialog, useValue: {} },
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}).compileComponents();
Here I am able to pass staffData
to the StaffAddComponent
. But I want to test different scenarios by passing different values for staffData