@@ -4,12 +4,13 @@ jest.mock("fs-extra", () => ({
44} ) ) ;
55
66import * as _fs from "fs-extra" ;
7- import makeParseOpenRPCDocument from "./parse-open-rpc-document" ;
7+ import makeParseOpenRPCDocument , { makeCustomResolver } from "./parse-open-rpc-document" ;
88import { OpenrpcDocument as OpenRPC , OpenrpcDocument } from "@open-rpc/meta-schema" ;
99import { OpenRPCDocumentValidationError } from "./validate-open-rpc-document" ;
1010import fetchUrlSchema from "./get-open-rpc-document-from-url" ;
1111import readSchemaFromFile from "./get-open-rpc-document-from-file" ;
1212import { OpenRPCDocumentDereferencingError } from "./dereference-document" ;
13+ import { JSONSchema } from "@json-schema-tools/meta-schema" ;
1314
1415const parseOpenRPCDocument = makeParseOpenRPCDocument ( fetchUrlSchema , readSchemaFromFile ) ;
1516const fs : any = _fs ;
@@ -248,6 +249,35 @@ describe("parseOpenRPCDocument", () => {
248249 }
249250 } ) ;
250251
252+ it ( "should make a reference resolver" , ( ) => {
253+ const resolver = makeCustomResolver ( { "file" :
254+ async ( ) : Promise < JSONSchema > => {
255+ return { }
256+ }
257+ } ) ;
258+ expect ( resolver ) . toBeDefined ( )
259+ } ) ;
260+
261+ it ( "should handle dereference option true" , async ( ) => {
262+ const document = await parseOpenRPCDocument ( workingDocument , {
263+ dereference : true ,
264+ } ) ;
265+ expect ( document . methods ) . toBeDefined ( ) ;
266+ } ) ;
267+
268+ it ( "should handle custom resolver option" , async ( ) => {
269+ const resolver = makeCustomResolver ( { "handler" :
270+ async ( uri : string ) : Promise < JSONSchema > => {
271+ return { }
272+ }
273+ } ) ;
274+ const document = await parseOpenRPCDocument ( workingDocument , {
275+ resolver
276+ } ) ;
277+ expect ( document . methods ) . toBeDefined ( ) ;
278+
279+ } ) ;
280+
251281 it ( "rejects when the json provided is invalid from file" , async ( ) => {
252282 expect . assertions ( 1 ) ;
253283 fs . readJson . mockClear ( ) ;
0 commit comments