@@ -35,31 +35,41 @@ const satisfyCriterionSample = {
3535 value : 3
3636} ;
3737
38- const aggregateAutoScoresSample = {
39- xfns1g7pga : {
40- ki : {
41- counts : { 1 : 2 , 2 : 0 , 3 : 1 , 4 : 0 , 5 : 0 } ,
42- scoreSum : 5 ,
43- scoreCount : 3 ,
44- average : 1.67
38+ const aggregateAutoScoresSample = [
39+ {
40+ nodeId : 'node1' ,
41+ componentId : 'xfns1g7pga' ,
42+ stepTitle : 'Step 1.1: Hello' ,
43+ aggregateAutoScore : {
44+ ki : {
45+ counts : { 1 : 2 , 2 : 0 , 3 : 1 , 4 : 0 , 5 : 0 } ,
46+ scoreSum : 5 ,
47+ scoreCount : 3 ,
48+ average : 1.67
49+ }
4550 }
4651 }
47- } ;
52+ ] ;
4853
4954const possibleScoresKi = [ 1 , 2 , 3 , 4 , 5 ] ;
5055
5156const sampleAggregateData = {
5257 counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
5358} ;
5459
55- const aggregateAutoScores50 = {
56- component1 : {
57- ki : {
58- counts : createScoreCounts ( [ 10 , 10 , 10 , 10 , 10 ] ) ,
59- scoreCount : 50
60+ const aggregateAutoScores50 = [
61+ {
62+ nodeId : 'node1' ,
63+ componentId : 'component1' ,
64+ stepTitle : 'Step 1.2: World' ,
65+ aggregateAutoScore : {
66+ ki : {
67+ counts : createScoreCounts ( [ 10 , 10 , 10 , 10 , 10 ] ) ,
68+ scoreCount : 50
69+ }
6070 }
6171 }
62- } ;
72+ ] ;
6373
6474const reportSettingsCustomScoreValuesSample = {
6575 customScoreValues : {
@@ -392,6 +402,12 @@ function insertMilestoneReport() {
392402 const content = 'template1Content' ;
393403 const milestone : any = {
394404 report : {
405+ locations : [
406+ {
407+ nodeId : 'node1' ,
408+ componentId : 'component1'
409+ }
410+ ] ,
395411 templates : [
396412 {
397413 id : 'template1' ,
@@ -509,6 +525,12 @@ function generateReport() {
509525 const content = 'template1Content' ;
510526 const projectAchievement = {
511527 report : {
528+ locations : [
529+ {
530+ nodeId : 'node1' ,
531+ componentId : 'component1'
532+ }
533+ ] ,
512534 templates : [
513535 {
514536 id : 'template1' ,
@@ -550,7 +572,7 @@ function chooseTemplate() {
550572 id : 'template-2'
551573 } ;
552574 const templates = [ template1 , template2 ] ;
553- const aggregateAutoScores = { } ;
575+ const aggregateAutoScores = [ ] ;
554576 spyOn ( service , 'isTemplateMatch' ) . and . callFake ( ( template , aggregateAutoScores ) => {
555577 if ( template . id === 'template-1' ) {
556578 return false ;
@@ -565,7 +587,7 @@ function chooseTemplate() {
565587
566588function isTemplateMatch ( ) {
567589 describe ( 'isTemplateMatch()' , ( ) => {
568- const aggregateAutoScores = { } ;
590+ const aggregateAutoScores = [ ] ;
569591 const satisfyCriteria = [
570592 {
571593 id : 'satisfy-criteria-1'
@@ -847,14 +869,19 @@ function isPercentOfScoresEqualTo() {
847869 ) . toEqual ( false ) ;
848870 } ) ;
849871 it ( 'should check is percent of scores equal to true' , ( ) => {
850- const aggregateAutoScores = {
851- component1 : {
852- ki : {
853- counts : createScoreCounts ( [ 10 , 0 , 10 , 0 , 0 ] ) ,
854- scoreCount : 20
872+ const aggregateAutoScores = [
873+ {
874+ nodeId : 'node1' ,
875+ componentId : 'component1' ,
876+ stepTitle : 'Step 1.1: Hello' ,
877+ aggregateAutoScore : {
878+ ki : {
879+ counts : createScoreCounts ( [ 10 , 0 , 10 , 0 , 0 ] ) ,
880+ scoreCount : 20
881+ }
855882 }
856883 }
857- } ;
884+ ] ;
858885 expect (
859886 service . isPercentOfScoresSatisfiesComparator (
860887 satisfyCriterion ,
@@ -877,7 +904,7 @@ function isPercentOfScoresNotEqualTo() {
877904 } ) ;
878905 it ( 'should return true when percent of scores equal to value meet threshold' , ( ) => {
879906 const aggregateAutoScores = angular . copy ( aggregateAutoScoresSample ) ;
880- aggregateAutoScores . xfns1g7pga . ki . counts = { 1 : 1 , 2 : 0 , 3 : 2 , 4 : 0 , 5 : 0 } ;
907+ aggregateAutoScores [ 0 ] . aggregateAutoScore . ki . counts = { 1 : 1 , 2 : 0 , 3 : 2 , 4 : 0 , 5 : 0 } ;
881908 expect (
882909 service . isPercentOfScoresSatisfiesComparator (
883910 satisfyCriterionSample ,
@@ -954,11 +981,15 @@ function getPossibleScores() {
954981function isPercentThresholdSatisfied ( ) {
955982 describe ( 'isPercentThresholdSatisfied()' , ( ) => {
956983 it ( 'should return true when percent threshold is satisfied' , ( ) => {
957- const aggregateAutoScores = {
958- xfns1g7pga : {
959- ki : { counts : { 1 : 1 , 2 : 0 , 3 : 2 , 4 : 0 , 5 : 0 } , scoreCount : 3 }
984+ const aggregateAutoScores = [
985+ {
986+ nodeId : 'node1' ,
987+ componentId : 'xfns1g7pga' ,
988+ aggregateAutoScore : {
989+ ki : { counts : { 1 : 1 , 2 : 0 , 3 : 2 , 4 : 0 , 5 : 0 } , scoreCount : 3 }
990+ }
960991 }
961- } ;
992+ ] ;
962993 const aggregateData = service . getAggregateData ( satisfyCriterionSample , aggregateAutoScores ) ;
963994 const sum = service . getComparatorSum (
964995 satisfyCriterionSample ,
@@ -1062,7 +1093,7 @@ function addDataToAggregate() {
10621093 ]
10631094 }
10641095 } ;
1065- const aggregateAutoScore = angular . copy ( aggregateAutoScoresSample ) . xfns1g7pga ;
1096+ const aggregateAutoScore = angular . copy ( aggregateAutoScoresSample ) [ 0 ] . aggregateAutoScore ;
10661097 const result = service . addDataToAggregate (
10671098 aggregateAutoScore ,
10681099 annotation ,
@@ -1144,40 +1175,27 @@ function processMilestoneGraphsAndData() {
11441175 describe ( 'processMilestoneGraphsAndData()' , ( ) => {
11451176 it ( 'should process milestone report graph' , ( ) => {
11461177 let content = '<milestone-report-graph id="ki"></milestone-report-graph>' ;
1147- const aggregateAutoScores = {
1148- component1 : {
1149- ki : {
1150- scoreSum : 4 ,
1151- scoreCount : 2 ,
1152- average : 2 ,
1153- counts : createScoreCounts ( [ 1 , 0 , 1 , 0 , 0 ] )
1154- }
1155- }
1156- } ;
1157- content = service . processMilestoneGraphsAndData ( content , aggregateAutoScores ) ;
1158- expect (
1159- content . includes (
1160- `data="{'scoreSum':4,'scoreCount':2,'average':2,'counts':{'1':1,'2':0,'3':1,'4':0,'5':0}}"`
1161- )
1162- ) . toEqual ( true ) ;
1163- } ) ;
1164- it ( 'should process milestone report data' , ( ) => {
1165- let content = '<milestone-report-data score-id="ki"></milestone-report-data>' ;
1166- const aggregateAutoScores = {
1167- component1 : {
1168- ki : {
1169- scoreSum : 4 ,
1170- scoreCount : 2 ,
1171- average : 2 ,
1172- counts : createScoreCounts ( [ 1 , 0 , 1 , 0 , 0 ] )
1178+ const componentAggregateAutoScores = [
1179+ {
1180+ nodeId : 'node1' ,
1181+ componentId : 'component1' ,
1182+ aggregateAutoScore : {
1183+ ki : {
1184+ scoreSum : 4 ,
1185+ scoreCount : 2 ,
1186+ average : 2 ,
1187+ counts : createScoreCounts ( [ 1 , 0 , 1 , 0 , 0 ] )
1188+ }
11731189 }
11741190 }
1175- } ;
1176- content = service . processMilestoneGraphsAndData ( content , aggregateAutoScores ) ;
1191+ ] ;
1192+ content = service . processMilestoneGraphsAndData ( content , componentAggregateAutoScores ) ;
11771193 expect (
11781194 content . includes (
1179- `data="{'scoreSum':4,'scoreCount':2,'average':2,` +
1180- `'counts':{'1':1,'2':0,'3':1,'4':0,'5':0}}"`
1195+ `data="[{` +
1196+ `'scoreSum':4,'scoreCount':2,'average':2,'counts':{'1':1,'2':0,'3':1,'4':0,'5':0},` +
1197+ `'nodeId':'node1','componentId':'component1'` +
1198+ `}]"`
11811199 )
11821200 ) . toEqual ( true ) ;
11831201 } ) ;
0 commit comments