@@ -12,6 +12,13 @@ describe("getDispute", () => {
1212 const mockCoreSubgraph = "https://api.thegraph.com/subgraphs/name/kleros/core" ;
1313 const mockDtrSubgraph = "https://api.thegraph.com/subgraphs/name/kleros/dtr" ;
1414
15+ const standardRefuseToArbitrateAnswer = {
16+ id : "0x0" ,
17+ title : "Refuse to Arbitrate / Invalid" ,
18+ description : "Refuse to Arbitrate / Invalid" ,
19+ reserved : true ,
20+ } ;
21+
1522 const mockDisputeDetails = {
1623 dispute : {
1724 templateId : 1 ,
@@ -52,12 +59,7 @@ describe("getDispute", () => {
5259 } ) ;
5360
5461 expect ( result ?. answers ) . toHaveLength ( 1 ) ;
55- expect ( result ?. answers [ 0 ] ) . toEqual ( {
56- id : "0x0" ,
57- title : "Refuse to Arbitrate / Invalid" ,
58- description : "Refuse to Arbitrate / Invalid" ,
59- reserved : true ,
60- } ) ;
62+ expect ( result ?. answers [ 0 ] ) . toEqual ( standardRefuseToArbitrateAnswer ) ;
6163 } ) ;
6264
6365 it ( "should add Refuse to Arbitrate option when it doesn't exist in answers" , async ( ) => {
@@ -98,18 +100,14 @@ describe("getDispute", () => {
98100 } ) ;
99101
100102 expect ( result ?. answers ) . toHaveLength ( 3 ) ;
101- expect ( result ?. answers [ 0 ] ) . toEqual ( {
102- id : "0x0" ,
103- title : "Refuse to Arbitrate / Invalid" ,
104- description : "Refuse to Arbitrate / Invalid" ,
105- reserved : true ,
106- } ) ;
103+ expect ( result ?. answers [ 0 ] ) . toEqual ( standardRefuseToArbitrateAnswer ) ;
107104 expect ( result ?. answers [ 1 ] . id ) . toBe ( "0x1" ) ;
108105 expect ( result ?. answers [ 2 ] . id ) . toBe ( "0x2" ) ;
109106 } ) ;
110107
111- it ( "should not add Refuse to Arbitrate option when it already exists with id 0x0" , async ( ) => {
112- const mockTemplate = {
108+ it ( "should overwrite existing answer with id 0x0 or 0x00" , async ( ) => {
109+ // Test with 0x0
110+ const mockTemplate0x0 = {
113111 disputeTemplate : {
114112 templateData : JSON . stringify ( {
115113 title : "Test Dispute" ,
@@ -118,8 +116,8 @@ describe("getDispute", () => {
118116 answers : [
119117 {
120118 id : "0x0" ,
121- title : "Refuse to Arbitrate / Invalid " ,
122- description : "Refuse to Arbitrate / Invalid " ,
119+ title : "Custom Refuse Title " ,
120+ description : "Custom Refuse Description " ,
123121 reserved : true ,
124122 } ,
125123 {
@@ -138,21 +136,20 @@ describe("getDispute", () => {
138136 } ;
139137
140138 vi . mocked ( fetchDisputeDetails ) . mockResolvedValue ( mockDisputeDetails ) ;
141- vi . mocked ( fetchDisputeTemplateFromId ) . mockResolvedValue ( mockTemplate ) ;
139+ vi . mocked ( fetchDisputeTemplateFromId ) . mockResolvedValue ( mockTemplate0x0 ) ;
142140
143- const result = await getDispute ( {
141+ let result = await getDispute ( {
144142 disputeId : mockDisputeId ,
145143 coreSubgraph : mockCoreSubgraph ,
146144 dtrSubgraph : mockDtrSubgraph ,
147145 } ) ;
148146
149147 expect ( result ?. answers ) . toHaveLength ( 2 ) ;
150- expect ( result ?. answers [ 0 ] . id ) . toBe ( "0x0" ) ;
148+ expect ( result ?. answers [ 0 ] ) . toEqual ( standardRefuseToArbitrateAnswer ) ;
151149 expect ( result ?. answers [ 1 ] . id ) . toBe ( "0x1" ) ;
152- } ) ;
153150
154- it ( "should not add Refuse to Arbitrate option when it already exists with id 0x00" , async ( ) => {
155- const mockTemplate = {
151+ // Test with 0x00
152+ const mockTemplate0x00 = {
156153 disputeTemplate : {
157154 templateData : JSON . stringify ( {
158155 title : "Test Dispute" ,
@@ -180,18 +177,16 @@ describe("getDispute", () => {
180177 } ,
181178 } ;
182179
183- vi . mocked ( fetchDisputeDetails ) . mockResolvedValue ( mockDisputeDetails ) ;
184- vi . mocked ( fetchDisputeTemplateFromId ) . mockResolvedValue ( mockTemplate ) ;
180+ vi . mocked ( fetchDisputeTemplateFromId ) . mockResolvedValue ( mockTemplate0x00 ) ;
185181
186- const result = await getDispute ( {
182+ result = await getDispute ( {
187183 disputeId : mockDisputeId ,
188184 coreSubgraph : mockCoreSubgraph ,
189185 dtrSubgraph : mockDtrSubgraph ,
190186 } ) ;
191187
192188 expect ( result ?. answers ) . toHaveLength ( 2 ) ;
193- expect ( result ?. answers [ 0 ] . id ) . toBe ( "0x00" ) ;
194- expect ( result ?. answers [ 0 ] . title ) . toBe ( "Custom Refuse Title" ) ;
189+ expect ( result ?. answers [ 0 ] ) . toEqual ( standardRefuseToArbitrateAnswer ) ;
195190 expect ( result ?. answers [ 1 ] . id ) . toBe ( "0x1" ) ;
196191 } ) ;
197192
0 commit comments