@@ -145,51 +145,30 @@ describe("router", () => {
145145 const { result } = await router . call ( "addition" , [ 6 , 2 ] ) ;
146146 expect ( typeof result ) . toBe ( "number" ) ;
147147 } ) ;
148- < < < << << Updated upstream
149- it ( "does not expose x-implementedBy client methods as inbound server methods" , async ( ) => {
150- const exampleWithClientMethod = _ . cloneDeep ( parsedExample ) ;
151- const additionMethod = ( exampleWithClientMethod . methods as MethodObject [ ] ) . find ( ( method ) => method . name === "addition" ) as MethodObject ;
152- ( additionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "client" ] ;
153- const router = new Router ( exampleWithClientMethod , makeMethodMapping ( exampleWithClientMethod . methods as MethodObject [ ] ) ) ;
154- = === ===
155148
156- it ( "plugin blocks methods not implemented by server" , async ( ) => {
149+ it ( "does not expose x-implementedBy client methods as inbound server methods " , async ( ) => {
157150 const exampleWithClientMethod = _ . cloneDeep ( parsedExample ) ;
158151 const additionMethod = ( exampleWithClientMethod . methods as MethodObject [ ] )
159152 . find ( ( method ) => method . name === "addition" ) as MethodObject ;
160153 ( additionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "client" ] ;
161-
162- const router = new Router (
163- exampleWithClientMethod ,
164- makeMethodMapping ( exampleWithClientMethod . methods as MethodObject [ ] ) ,
165- { plugins : [ implementedByPlugin ( ) ] } ,
166- ) ;
167- > >>> >>> Stashed changes
154+ const router = new Router ( exampleWithClientMethod , makeMethodMapping ( exampleWithClientMethod . methods as MethodObject [ ] ) ) ;
168155 const { error } = await router . call ( "addition" , [ 2 , 2 ] ) ;
169156 expect ( ( error as JSONRPCErrorObject ) . code ) . toBe ( - 32601 ) ;
170157 } ) ;
171158
172- < < < << << Updated upstream
173159 it ( "reports methods implemented by a given participant" , async ( ) => {
174160 const exampleWithClientMethod = _ . cloneDeep ( parsedExample ) ;
175161 const methods = exampleWithClientMethod . methods as MethodObject [ ] ;
176- = === ===
177- it ( "plugin reports available methods using plugin context" , ( ) => {
178- const exampleWithRoles = _ . cloneDeep ( parsedExample ) ;
179- const methods = exampleWithRoles . methods as MethodObject [ ] ;
180- > >>> >>> Stashed changes
181162 const additionMethod = methods . find ( ( method ) => method . name === "addition" ) as MethodObject ;
182163 const subtractionMethod = methods . find ( ( method ) => method . name === "subtraction" ) as MethodObject ;
183164 ( additionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "client" ] ;
184165 ( subtractionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "server" , "client" ] ;
185166
186- < < < << << Updated upstream
187167 const router = new Router ( exampleWithClientMethod , makeMethodMapping ( methods ) ) ;
188168 expect ( router . getMethodsImplementedBy ( "client" ) ) . toEqual ( expect . arrayContaining ( [ "addition" , "subtraction" ] ) ) ;
189169 expect ( router . getMethodsImplementedBy ( "server" ) ) . toContain ( "subtraction" ) ;
190170 } ) ;
191171
192-
193172 it ( "defaults x-implementedBy to server when extension is omitted" , async ( ) => {
194173 const exampleWithoutExtension = _ . cloneDeep ( parsedExample ) ;
195174 const additionMethod = ( exampleWithoutExtension . methods as MethodObject [ ] )
@@ -207,7 +186,14 @@ describe("router", () => {
207186 expect ( router . getMethodsImplementedBy ( "server" ) ) . not . toContain ( "rpc.discover" ) ;
208187 } ) ;
209188
210- === = ===
189+ it ( "plugin reports available methods using plugin context" , ( ) => {
190+ const exampleWithRoles = _ . cloneDeep ( parsedExample ) ;
191+ const methods = exampleWithRoles . methods as MethodObject [ ] ;
192+ const additionMethod = methods . find ( ( method ) => method . name === "addition" ) as MethodObject ;
193+ const subtractionMethod = methods . find ( ( method ) => method . name === "subtraction" ) as MethodObject ;
194+ ( additionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "client" ] ;
195+ ( subtractionMethod as MethodObject & { [ key : string ] : unknown } ) [ "x-implementedBy" ] = [ "server" , "client" ] ;
196+
211197 const router = new Router (
212198 exampleWithRoles ,
213199 makeMethodMapping ( methods ) ,
@@ -235,7 +221,6 @@ describe("router", () => {
235221 const { result } = await router . call ( "addition" , [ 2 , 2 ] , { client : expectedClient } ) ;
236222 expect ( result ) . toBe ( 4 ) ;
237223 } ) ;
238- >>> > >>> Stashed changes
239224 }
240225
241226 } ) ;
0 commit comments