Skip to content

Commit 14538c2

Browse files
authored
Merge pull request #175 from 0x41head/master
Added more tests
2 parents 32d8afd + d0eed07 commit 14538c2

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

src/app/component/task-description/task-description.component.spec.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HttpClient, HttpHandler } from '@angular/common/http';
22
import { ComponentFixture, TestBed } from '@angular/core/testing';
33
import { RouterTestingModule } from '@angular/router/testing';
4+
import { sample } from 'rxjs';
45
import { ymlService } from 'src/app/service/yaml-parser/yaml-parser.service';
56

67
import { TaskDescriptionComponent } from './task-description.component';
@@ -26,4 +27,69 @@ describe('TaskDescriptionComponent', () => {
2627
it('should create', () => {
2728
expect(component).toBeTruthy();
2829
});
30+
31+
it('check if header is being genenrated', () => {
32+
const testDimension = 'Sample Dimension';
33+
const testSubDimension = 'Sample subDimension';
34+
component.currentTask.dimension = testDimension;
35+
component.currentTask.subDimension = testSubDimension;
36+
fixture.detectChanges();
37+
const HTMLElement: HTMLElement = fixture.nativeElement;
38+
const heading = HTMLElement.querySelector('h1')!;
39+
expect(heading.textContent).toContain(testDimension);
40+
expect(heading.textContent).toContain(testSubDimension);
41+
});
42+
43+
it('check if description is being genenrated', () => {
44+
const testDescription = 'Sample Description';
45+
component.currentTask.description = testDescription;
46+
fixture.detectChanges();
47+
const HTMLElement: HTMLElement = fixture.nativeElement;
48+
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
49+
expect(contentDisplayedinParagraphTag[0].textContent).toContain(
50+
testDescription
51+
);
52+
});
53+
54+
it('check if risk is being genenrated', () => {
55+
const testRisk = 'Sample Risk';
56+
component.currentTask.risk = testRisk;
57+
fixture.detectChanges();
58+
const HTMLElement: HTMLElement = fixture.nativeElement;
59+
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
60+
expect(contentDisplayedinParagraphTag[1].textContent).toContain(testRisk);
61+
});
62+
63+
it('check if measure is being genenrated', () => {
64+
const testMeasure = 'Sample Measure';
65+
component.currentTask.measure = testMeasure;
66+
fixture.detectChanges();
67+
const HTMLElement: HTMLElement = fixture.nativeElement;
68+
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
69+
expect(contentDisplayedinParagraphTag[2].textContent).toContain(
70+
testMeasure
71+
);
72+
});
73+
74+
it('check if implementation guide is being genenrated', () => {
75+
const testImplementationGuide = 'Sample Implementation Guide';
76+
component.currentTask.implementatonGuide = testImplementationGuide;
77+
fixture.detectChanges();
78+
const HTMLElement: HTMLElement = fixture.nativeElement;
79+
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
80+
expect(contentDisplayedinParagraphTag[3].textContent).toContain(
81+
testImplementationGuide
82+
);
83+
});
84+
85+
it('check if evidence is being genenrated', () => {
86+
const testEvidence = 'Sample Evidence';
87+
component.currentTask.evidence = testEvidence;
88+
fixture.detectChanges();
89+
const HTMLElement: HTMLElement = fixture.nativeElement;
90+
const contentDisplayedinParagraphTag = HTMLElement.querySelectorAll('p')!;
91+
expect(contentDisplayedinParagraphTag[6].textContent).toContain(
92+
testEvidence
93+
);
94+
});
2995
});

0 commit comments

Comments
 (0)