@@ -5,18 +5,29 @@ import { sample } from 'rxjs';
55import { ymlService } from 'src/app/service/yaml-parser/yaml-parser.service' ;
66
77import { ActivityDescriptionComponent } from './activity-description.component' ;
8+ import { LoaderService } from 'src/app/service/loader/data-loader.service' ;
9+ import { MockLoaderService } from 'src/app/service/loader/mock-data-loader.service' ;
10+
11+ let mockLoaderService : MockLoaderService ;
812
913describe ( 'ActivityDescriptionComponent' , ( ) => {
1014 let component : ActivityDescriptionComponent ;
1115 let fixture : ComponentFixture < ActivityDescriptionComponent > ;
16+ mockLoaderService = new MockLoaderService ( { } ) ;
1217
18+ /* eslint-disable */
1319 beforeEach ( async ( ) => {
1420 await TestBed . configureTestingModule ( {
15- providers : [ ymlService , HttpClient , HttpHandler ] ,
21+ providers : [
22+ HttpClient ,
23+ HttpHandler ,
24+ { provide : LoaderService , useValue : mockLoaderService } ,
25+ ] ,
1626 imports : [ RouterTestingModule ] ,
1727 declarations : [ ActivityDescriptionComponent ] ,
1828 } ) . compileComponents ( ) ;
1929 } ) ;
30+ /* eslint-enable */
2031
2132 beforeEach ( ( ) => {
2233 fixture = TestBed . createComponent ( ActivityDescriptionComponent ) ;
@@ -31,8 +42,8 @@ describe('ActivityDescriptionComponent', () => {
3142 it ( 'check if header is being generated' , ( ) => {
3243 const testDimension = 'Sample Dimension' ;
3344 const testSubDimension = 'Sample subDimension' ;
34- component . currentActivity . dimension = testDimension ;
35- component . currentActivity . subDimension = testSubDimension ;
45+ component . currentActivity . category = testDimension ;
46+ component . currentActivity . dimension = testSubDimension ;
3647 fixture . detectChanges ( ) ;
3748 const HTMLElement : HTMLElement = fixture . nativeElement ;
3849 const heading = HTMLElement . querySelector ( 'h1' ) ! ;
@@ -54,11 +65,8 @@ describe('ActivityDescriptionComponent', () => {
5465 component . currentActivity . description = testDescription ;
5566 fixture . detectChanges ( ) ;
5667 const HTMLElement : HTMLElement = fixture . nativeElement ;
57- const contentDisplayedinParagraphTag =
58- HTMLElement . querySelector ( '#description' ) ! ;
59- expect ( contentDisplayedinParagraphTag . textContent ) . toContain (
60- testDescription
61- ) ;
68+ const contentDisplayedinParagraphTag = HTMLElement . querySelector ( '#description' ) ! ;
69+ expect ( contentDisplayedinParagraphTag . textContent ) . toContain ( testDescription ) ;
6270 } ) ;
6371
6472 it ( 'check if risk is being generated' , ( ) => {
@@ -75,8 +83,7 @@ describe('ActivityDescriptionComponent', () => {
7583 component . currentActivity . measure = testMeasure ;
7684 fixture . detectChanges ( ) ;
7785 const HTMLElement : HTMLElement = fixture . nativeElement ;
78- const contentDisplayedinParagraphTag =
79- HTMLElement . querySelector ( '#measure' ) ! ;
86+ const contentDisplayedinParagraphTag = HTMLElement . querySelector ( '#measure' ) ! ;
8087 expect ( contentDisplayedinParagraphTag . textContent ) . toContain ( testMeasure ) ;
8188 } ) ;
8289
@@ -85,12 +92,8 @@ describe('ActivityDescriptionComponent', () => {
8592 component . currentActivity . implementatonGuide = testImplementationGuide ;
8693 fixture . detectChanges ( ) ;
8794 const HTMLElement : HTMLElement = fixture . nativeElement ;
88- const contentDisplayedinParagraphTag = HTMLElement . querySelector (
89- '#implementatonGuide'
90- ) ! ;
91- expect ( contentDisplayedinParagraphTag . textContent ) . toContain (
92- testImplementationGuide
93- ) ;
95+ const contentDisplayedinParagraphTag = HTMLElement . querySelector ( '#implementatonGuide' ) ! ;
96+ expect ( contentDisplayedinParagraphTag . textContent ) . toContain ( testImplementationGuide ) ;
9497 } ) ;
9598
9699 it ( 'check if evidence is being generated' , ( ) => {
@@ -102,30 +105,24 @@ describe('ActivityDescriptionComponent', () => {
102105 console . log ( 'parentElement' , parentElement [ 1 ] . textContent ) ;
103106 const lengthOfObject = Object . keys ( testEvidence ) . length ;
104107 for ( var i = 0 ; i > lengthOfObject ; i ++ )
105- expect ( parentElement [ i ] . textContent ) . toContain (
106- Object . keys ( testEvidence ) [ i ] + Object . values ( testEvidence ) [ i ]
107- ) ;
108+ expect ( parentElement [ i ] . textContent ) . toContain ( Object . keys ( testEvidence ) [ i ] + Object . values ( testEvidence ) [ i ] ) ;
108109 } ) ;
109110
110111 it ( 'check if assessment is being generated' , ( ) => {
111112 const testAssessment = 'Sample Assessment' ;
112113 component . currentActivity . assessment = testAssessment ;
113114 fixture . detectChanges ( ) ;
114115 const HTMLElement : HTMLElement = fixture . nativeElement ;
115- const contentDisplayedinParagraphTag =
116- HTMLElement . querySelector ( '#assessment' ) ! ;
117- expect ( contentDisplayedinParagraphTag . textContent ) . toContain (
118- testAssessment
119- ) ;
116+ const contentDisplayedinParagraphTag = HTMLElement . querySelector ( '#assessment' ) ! ;
117+ expect ( contentDisplayedinParagraphTag . textContent ) . toContain ( testAssessment ) ;
120118 } ) ;
121119
122120 it ( 'check if comments is being generated' , ( ) => {
123121 const testComments = 'Sample Comments' ;
124122 component . currentActivity . comments = testComments ;
125123 fixture . detectChanges ( ) ;
126124 const HTMLElement : HTMLElement = fixture . nativeElement ;
127- const contentDisplayedinParagraphTag =
128- HTMLElement . querySelector ( '#comments' ) ! ;
125+ const contentDisplayedinParagraphTag = HTMLElement . querySelector ( '#comments' ) ! ;
129126 expect ( contentDisplayedinParagraphTag . textContent ) . toContain ( testComments ) ;
130127 } ) ;
131128
@@ -142,8 +139,7 @@ describe('ActivityDescriptionComponent', () => {
142139
143140 fixture . detectChanges ( ) ;
144141 const HTMLElement : HTMLElement = fixture . nativeElement ;
145- const contentDisplayedinParagraphTag =
146- HTMLElement . querySelectorAll ( '#references' ) ! ;
142+ const contentDisplayedinParagraphTag = HTMLElement . querySelectorAll ( '#references' ) ! ;
147143
148144 expect ( contentDisplayedinParagraphTag [ 0 ] . textContent ) . toContain (
149145 component . SAMMVersion +
@@ -152,8 +148,7 @@ describe('ActivityDescriptionComponent', () => {
152148 testISO [ 0 ] +
153149 component . ISO22Version +
154150 testISO22 [ 0 ] +
155- component . openCREVersion +
156- uuid
151+ component . openCREVersion
157152 ) ;
158153 } ) ;
159154} ) ;
0 commit comments