11import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2-
3- import { ModalMessageComponent } from './modal-message.component' ;
2+ import { DialogInfo , ModalMessageComponent } from './modal-message.component' ;
3+ import { MatDialogRef , MAT_DIALOG_DATA } from '@angular/material/dialog' ;
4+ import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
5+ import { MatDialogModule } from '@angular/material/dialog' ;
46
57describe ( 'ModalMessageComponent' , ( ) => {
68 let component : ModalMessageComponent ;
79 let fixture : ComponentFixture < ModalMessageComponent > ;
810
911 beforeEach ( async ( ) => {
1012 await TestBed . configureTestingModule ( {
13+ imports : [ NoopAnimationsModule , MatDialogModule ] ,
1114 declarations : [ ModalMessageComponent ] ,
15+ providers : [
16+ { provide : MatDialogRef , useValue : { } } ,
17+ { provide : MAT_DIALOG_DATA , useValue : { } } ,
18+ ] ,
1219 } ) . compileComponents ( ) ;
1320 } ) ;
1421
@@ -21,4 +28,25 @@ describe('ModalMessageComponent', () => {
2128 it ( 'should create' , ( ) => {
2229 expect ( component ) . toBeTruthy ( ) ;
2330 } ) ;
31+
32+ it ( 'should render markdown correctly in the dialog' , ( ) => {
33+ const dialogInfo : DialogInfo = new DialogInfo ( 'A **test** markdown.' ) ;
34+ const dialogRef : MatDialogRef < ModalMessageComponent > =
35+ component . openDialog ( dialogInfo ) ;
36+
37+ expect ( dialogRef . componentInstance . data . message ) . toContain (
38+ '<strong>test</strong>'
39+ ) ;
40+ } ) ;
41+
42+ it ( 'should render markdown correctly in the dialog' , ( ) => {
43+ const dialogInfo : DialogInfo = new DialogInfo ( 'A **test** markdown.' ) ;
44+ const dialogRef : MatDialogRef < ModalMessageComponent > =
45+ component . openDialog ( dialogInfo ) ;
46+
47+ // Check if markdown rendering is applied
48+ expect ( dialogRef . componentInstance . data . message ) . toContain (
49+ '<strong>test</strong>'
50+ ) ;
51+ } ) ;
2452} ) ;
0 commit comments