11import { HttpClient , HttpHandler } from '@angular/common/http' ;
22import { ComponentFixture , TestBed } from '@angular/core/testing' ;
33import { RouterTestingModule } from '@angular/router/testing' ;
4+ import { sample } from 'rxjs' ;
45import { ymlService } from 'src/app/service/yaml-parser/yaml-parser.service' ;
56
67import { 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