@@ -48,6 +48,10 @@ const aggregateAutoScoresSample = {
4848
4949const possibleScoresKi = [ 1 , 2 , 3 , 4 , 5 ] ;
5050
51+ const sampleAggregateData = {
52+ counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
53+ } ;
54+
5155const reportSettingsCustomScoreValuesSample = {
5256 customScoreValues : {
5357 ki : [ 1 , 2 , 3 , 4 ]
@@ -964,205 +968,39 @@ function isPercentOfScoresNotEqualTo() {
964968
965969function getComparatorSum ( ) {
966970 describe ( 'getComparatorSum()' , ( ) => {
967- getGreaterThanSum ( ) ;
968- getGreaterThanOrEqualToSum ( ) ;
969- getLessThanSum ( ) ;
970- getEqualToSum ( ) ;
971- getNotEqualToSum ( ) ;
972- } ) ;
973- }
974-
975- function getGreaterThanSum ( ) {
976- const aggregateData = {
977- counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
978- } ;
979- it ( 'should get greater than sum with score 1' , ( ) => {
980- const satisfyCriterion = { value : 1 } ;
981- expect (
982- service . getComparatorSum (
983- satisfyCriterion ,
984- aggregateData ,
985- possibleScoresKi ,
986- utilService . greaterThan
987- )
988- ) . toEqual ( 140 ) ;
989- } ) ;
990- it ( 'should get greater than sum with score 2' , ( ) => {
991- const satisfyCriterion = { value : 2 } ;
992- expect (
993- service . getComparatorSum (
994- satisfyCriterion ,
995- aggregateData ,
996- possibleScoresKi ,
997- utilService . greaterThan
998- )
999- ) . toEqual ( 120 ) ;
1000- } ) ;
1001- it ( 'should get greater than sum with score 3' , ( ) => {
1002- const satisfyCriterion = { value : 3 } ;
1003- expect (
1004- service . getComparatorSum (
1005- satisfyCriterion ,
1006- aggregateData ,
1007- possibleScoresKi ,
1008- utilService . greaterThan
1009- )
1010- ) . toEqual ( 90 ) ;
1011- } ) ;
1012- it ( 'should get greater than sum with score 4' , ( ) => {
1013- const satisfyCriterion = { value : 4 } ;
1014- expect (
1015- service . getComparatorSum (
1016- satisfyCriterion ,
1017- aggregateData ,
1018- possibleScoresKi ,
1019- utilService . greaterThan
1020- )
1021- ) . toEqual ( 50 ) ;
971+ getComparatorSum_greaterThan0_ReturnSumAll ( ) ;
972+ getComparatorSum_greaterThan3_ReturnSumPartial ( ) ;
973+ getComparatorSum_greaterThan5_Return0 ( ) ;
1022974 } ) ;
1023975}
1024976
1025- function getGreaterThanOrEqualToSum ( ) {
1026- const aggregateData = {
1027- counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
1028- } ;
1029- it ( 'should get greater than or equal to sum with score 1' , ( ) => {
1030- const satisfyCriterion = { value : 1 } ;
1031- expect (
1032- service . getComparatorSum (
1033- satisfyCriterion ,
1034- aggregateData ,
1035- possibleScoresKi ,
1036- utilService . greaterThanEqualTo
1037- )
1038- ) . toEqual ( 150 ) ;
1039- } ) ;
1040- it ( 'should get greater than or equal to sum with score 2' , ( ) => {
1041- const satisfyCriterion = { value : 2 } ;
1042- expect (
1043- service . getComparatorSum (
1044- satisfyCriterion ,
1045- aggregateData ,
1046- possibleScoresKi ,
1047- utilService . greaterThanEqualTo
1048- )
1049- ) . toEqual ( 140 ) ;
1050- } ) ;
1051- it ( 'should get greater than or equal to sum with score 3' , ( ) => {
1052- const satisfyCriterion = { value : 3 } ;
1053- expect (
1054- service . getComparatorSum (
1055- satisfyCriterion ,
1056- aggregateData ,
1057- possibleScoresKi ,
1058- utilService . greaterThanEqualTo
1059- )
1060- ) . toEqual ( 120 ) ;
1061- } ) ;
1062- it ( 'should get greater than or equal to sum with score 4' , ( ) => {
1063- const satisfyCriterion = { value : 4 } ;
1064- expect (
1065- service . getComparatorSum (
1066- satisfyCriterion ,
1067- aggregateData ,
1068- possibleScoresKi ,
1069- utilService . greaterThanEqualTo
1070- )
1071- ) . toEqual ( 90 ) ;
1072- } ) ;
1073- it ( 'should get greater than or equal to sum with score 5' , ( ) => {
1074- const satisfyCriterion = { value : 5 } ;
1075- expect (
1076- service . getComparatorSum (
1077- satisfyCriterion ,
1078- aggregateData ,
1079- possibleScoresKi ,
1080- utilService . greaterThanEqualTo
1081- )
1082- ) . toEqual ( 50 ) ;
1083- } ) ;
977+ function expectComparatorResult ( satisfyCriterionValue : number , expectedResult : number ) {
978+ const satisfyCriterion = { value : satisfyCriterionValue } ;
979+ expect (
980+ service . getComparatorSum (
981+ satisfyCriterion ,
982+ sampleAggregateData ,
983+ possibleScoresKi ,
984+ utilService . greaterThan
985+ )
986+ ) . toEqual ( expectedResult ) ;
1084987}
1085988
1086- function getLessThanSum ( ) {
1087- const aggregateData = {
1088- counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
1089- } ;
1090- it ( 'should get less than sum with score 2' , ( ) => {
1091- const satisfyCriterion = { value : 2 } ;
1092- expect (
1093- service . getComparatorSum (
1094- satisfyCriterion ,
1095- aggregateData ,
1096- possibleScoresKi ,
1097- utilService . lessThan
1098- )
1099- ) . toEqual ( 10 ) ;
1100- } ) ;
1101- it ( 'should get less than sum with score 3' , ( ) => {
1102- const satisfyCriterion = { value : 3 } ;
1103- expect (
1104- service . getComparatorSum (
1105- satisfyCriterion ,
1106- aggregateData ,
1107- possibleScoresKi ,
1108- utilService . lessThan
1109- )
1110- ) . toEqual ( 30 ) ;
1111- } ) ;
1112- it ( 'should get less than sum with score 4' , ( ) => {
1113- const satisfyCriterion = { value : 4 } ;
1114- expect (
1115- service . getComparatorSum (
1116- satisfyCriterion ,
1117- aggregateData ,
1118- possibleScoresKi ,
1119- utilService . lessThan
1120- )
1121- ) . toEqual ( 60 ) ;
1122- } ) ;
1123- it ( 'should get less than sum with score 5' , ( ) => {
1124- const satisfyCriterion = { value : 5 } ;
1125- expect (
1126- service . getComparatorSum (
1127- satisfyCriterion ,
1128- aggregateData ,
1129- possibleScoresKi ,
1130- utilService . lessThan
1131- )
1132- ) . toEqual ( 100 ) ;
989+ function getComparatorSum_greaterThan0_ReturnSumAll ( ) {
990+ it ( 'should get greater than sum with score 0' , ( ) => {
991+ expectComparatorResult ( 0 , 150 ) ;
1133992 } ) ;
1134993}
1135994
1136- function getEqualToSum ( ) {
1137- it ( 'should return the sum of scores equal to value' , ( ) => {
1138- const satisfyCriterion = { value : 3 } ;
1139- const aggregateData = {
1140- counts : createScoreCounts ( [ 10 , 20 , 30 , 40 , 50 ] )
1141- } ;
1142- expect (
1143- service . getComparatorSum (
1144- satisfyCriterion ,
1145- aggregateData ,
1146- possibleScoresKi ,
1147- utilService . equalTo
1148- )
1149- ) . toEqual ( 30 ) ;
995+ function getComparatorSum_greaterThan3_ReturnSumPartial ( ) {
996+ it ( 'should get greater than sum with score 3' , ( ) => {
997+ expectComparatorResult ( 3 , 90 ) ;
1150998 } ) ;
1151999}
11521000
1153- function getNotEqualToSum ( ) {
1154- const aggregateData = {
1155- counts : { 1 : 2 , 2 : 0 , 3 : 1 , 4 : 0 , 5 : 0 } ,
1156- scoreCount : 3
1157- } ;
1158- it ( 'should return the sum of scores not equal to value' , ( ) => {
1159- const result = service . getComparatorSum (
1160- satisfyCriterionSample ,
1161- aggregateData ,
1162- possibleScoresKi ,
1163- utilService . notEqualTo
1164- ) ;
1165- expect ( result ) . toBe ( 2 ) ;
1001+ function getComparatorSum_greaterThan5_Return0 ( ) {
1002+ it ( 'should get greater than sum with score 5' , ( ) => {
1003+ expectComparatorResult ( 5 , 0 ) ;
11661004 } ) ;
11671005}
11681006
0 commit comments