@@ -3,8 +3,8 @@ import { getProposalValue } from '../../../src/helpers/entityValue';
33describe ( 'getProposalValue' , ( ) => {
44 it ( 'should calculate correct proposal value with single strategy' , ( ) => {
55 const proposal = {
6- scores_by_strategy : ' [[100], [200]]' ,
7- vp_value_by_strategy : ' [2.5]'
6+ scores_by_strategy : [ [ 100 ] , [ 200 ] ] ,
7+ vp_value_by_strategy : [ 2.5 ]
88 } ;
99
1010 const result = getProposalValue ( proposal ) ;
@@ -14,8 +14,12 @@ describe('getProposalValue', () => {
1414
1515 it ( 'should calculate correct proposal value with multiple strategies' , ( ) => {
1616 const proposal = {
17- scores_by_strategy : '[[100, 50], [200, 75], [300, 25]]' ,
18- vp_value_by_strategy : '[1.5, 3.0]'
17+ scores_by_strategy : [
18+ [ 100 , 50 ] ,
19+ [ 200 , 75 ] ,
20+ [ 300 , 25 ]
21+ ] ,
22+ vp_value_by_strategy : [ 1.5 , 3.0 ]
1923 } ;
2024
2125 const result = getProposalValue ( proposal ) ;
@@ -25,8 +29,8 @@ describe('getProposalValue', () => {
2529
2630 it ( 'should return 0 when scores_by_strategy is empty' , ( ) => {
2731 const proposal = {
28- scores_by_strategy : '[]' ,
29- vp_value_by_strategy : ' [2.0]'
32+ scores_by_strategy : [ ] ,
33+ vp_value_by_strategy : [ 2.0 ]
3034 } ;
3135
3236 const result = getProposalValue ( proposal ) ;
@@ -36,8 +40,8 @@ describe('getProposalValue', () => {
3640
3741 it ( 'should return 0 when first strategy array is empty' , ( ) => {
3842 const proposal = {
39- scores_by_strategy : ' [[]]' ,
40- vp_value_by_strategy : ' [2.0]'
43+ scores_by_strategy : [ [ ] ] ,
44+ vp_value_by_strategy : [ 2.0 ]
4145 } ;
4246
4347 const result = getProposalValue ( proposal ) ;
@@ -47,8 +51,11 @@ describe('getProposalValue', () => {
4751
4852 it ( 'should handle zero values correctly' , ( ) => {
4953 const proposal = {
50- scores_by_strategy : '[[0, 0], [0, 0]]' ,
51- vp_value_by_strategy : '[2.0, 1.5]'
54+ scores_by_strategy : [
55+ [ 0 , 0 ] ,
56+ [ 0 , 0 ]
57+ ] ,
58+ vp_value_by_strategy : [ 2.0 , 1.5 ]
5259 } ;
5360
5461 const result = getProposalValue ( proposal ) ;
@@ -58,8 +65,11 @@ describe('getProposalValue', () => {
5865
5966 it ( 'should handle zero vp_value_by_strategy correctly' , ( ) => {
6067 const proposal = {
61- scores_by_strategy : '[[100, 50], [200, 75]]' ,
62- vp_value_by_strategy : '[0, 0]'
68+ scores_by_strategy : [
69+ [ 100 , 50 ] ,
70+ [ 200 , 75 ]
71+ ] ,
72+ vp_value_by_strategy : [ 0 , 0 ]
6373 } ;
6474
6575 const result = getProposalValue ( proposal ) ;
@@ -69,8 +79,11 @@ describe('getProposalValue', () => {
6979
7080 it ( 'should handle decimal values correctly' , ( ) => {
7181 const proposal = {
72- scores_by_strategy : '[[10.5, 20.5], [15.5, 25.5]]' ,
73- vp_value_by_strategy : '[0.1, 0.2]'
82+ scores_by_strategy : [
83+ [ 10.5 , 20.5 ] ,
84+ [ 15.5 , 25.5 ]
85+ ] ,
86+ vp_value_by_strategy : [ 0.1 , 0.2 ]
7487 } ;
7588
7689 const result = getProposalValue ( proposal ) ;
@@ -80,30 +93,12 @@ describe('getProposalValue', () => {
8093
8194 it ( 'should handle single vote scenario' , ( ) => {
8295 const proposal = {
83- scores_by_strategy : ' [[100]]' ,
84- vp_value_by_strategy : ' [2.0]'
96+ scores_by_strategy : [ [ 100 ] ] ,
97+ vp_value_by_strategy : [ 2.0 ]
8598 } ;
8699
87100 const result = getProposalValue ( proposal ) ;
88101
89102 expect ( result ) . toBe ( 200 ) ; // 100 * 2.0 = 200
90103 } ) ;
91-
92- it ( 'should throw error for invalid JSON in scores_by_strategy' , ( ) => {
93- const proposal = {
94- scores_by_strategy : 'invalid json' ,
95- vp_value_by_strategy : '[2.0]'
96- } ;
97-
98- expect ( ( ) => getProposalValue ( proposal ) ) . toThrow ( ) ;
99- } ) ;
100-
101- it ( 'should throw error for invalid JSON in vp_value_by_strategy' , ( ) => {
102- const proposal = {
103- scores_by_strategy : '[[100]]' ,
104- vp_value_by_strategy : 'invalid json'
105- } ;
106-
107- expect ( ( ) => getProposalValue ( proposal ) ) . toThrow ( ) ;
108- } ) ;
109104} ) ;
0 commit comments