Вы можете попробовать что-то вроде ниже:
it('should show Cancel Details Dialog', async(() => {
component.openCancelDetailsDialog(policyResult);
fixture.detectChanges();
fixture.whenStable().then(() => {
let dialogBox: HTMLCollectionOf<Element> = document.getElementsByClassName('.class-name-available-on-dialog');
expect(dialogBox).not.toBeNull();
let restoreText = dialogBox[1].querySelector('.your-dialog-content-class').innerHTML;
expect(restoreText.toUpperCase()).toContain('your text here');
});
}));
Edit:
Вы можете попробовать, как показано ниже:
describe('Dialog Test', () => {
let component: CancelGroup1PolicyDialogComponent;
let fixture: ComponentFixture<CancelGroup1PolicyDialogComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TestModule
],
providers: [],
});
});
beforeEach(() => {
fixture = TestBed.createComponent(CancelGroup1PolicyDialogComponent);
component = fixture.componentInstance;
});
it('should show Cancel Details Dialog', async(() => {
component.openCancelDetailsDialog(policyResult);
fixture.detectChanges();
fixture.whenStable().then(() => {
let dialogBox: HTMLCollectionOf<Element> = document.getElementsByClassName('.class-name-available-on-dialog');
expect(dialogBox).not.toBeNull();
let restoreText = dialogBox[1].querySelector('.your-dialog-content-class').innerHTML;
expect(restoreText.toUpperCase()).toContain('your text here');
});
}));
});
@NgModule({
imports: [],
declarations: [],
entryComponents: [
CancelGroup1DetailsDialogComponent,
],
})
class TestModule {
}