Skip to content

Commit 1db756e

Browse files
committed
Updated test files for modal and heatmap
1 parent 39cb156 commit 1db756e

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

src/app/component/circular-heatmap/circular-heatmap.component.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ import { ymlService } from 'src/app/service/yaml-parser/yaml-parser.service';
44
import { CircularHeatmapComponent } from './circular-heatmap.component';
55
import { RouterTestingModule } from '@angular/router/testing';
66
import { MatChip } from '@angular/material/chips';
7+
import { ModalMessageComponent } from '../modal-message/modal-message.component';
78

89
describe('CircularHeatmapComponent', () => {
910
let component: CircularHeatmapComponent;
1011
let fixture: ComponentFixture<CircularHeatmapComponent>;
1112

1213
beforeEach(async () => {
1314
await TestBed.configureTestingModule({
14-
providers: [ymlService, HttpClient, HttpHandler],
15+
declarations: [CircularHeatmapComponent, MatChip],
1516
imports: [RouterTestingModule],
16-
declarations: [CircularHeatmapComponent],
17+
providers: [
18+
ymlService,
19+
HttpClient,
20+
HttpHandler,
21+
{ provide: ModalMessageComponent, useValue: {} },
22+
],
1723
}).compileComponents();
18-
});
19-
beforeEach(async () => {
20-
TestBed.configureTestingModule({
21-
declarations: [MatChip],
22-
}).compileComponents();
23-
});
2424

25-
beforeEach(() => {
26-
fixture = TestBed.createComponent(CircularHeatmapComponent);
25+
fixture = TestBed.createComponent(CircularHeatmapComponent); // Create fixture and component here
2726
component = fixture.componentInstance;
2827
fixture.detectChanges();
2928
});

src/app/component/modal-message/modal-message.component.spec.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { 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

57
describe('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

Comments
 (0)