@@ -9,28 +9,39 @@ const createStoplightDefaults = require("../../../lib/bundle/stoplight/defaults"
99const cwd = typeof window === "object" ? location . origin + "/base/test/specs/custom-bundling-roots-new-stoplight" : __dirname ;
1010
1111describe ( "Stoplight-specific defaults" , ( ) => {
12- it ( "should recognize platform references" , async ( ) => {
13- let defaults = createStoplightDefaults ( {
14- cwd,
15- endpointUrl : "http://jakub.stoplight-local.com:8080/api/v1/projects/jakub/my-project/nodes" ,
16- } ) ;
12+ let model ;
1713
14+ beforeEach ( ( ) => {
1815 setupHttpMocks ( {
1916 "http://jakub.stoplight-local.com:8080/api/v1/projects/jakub/my-project/nodes/reference/Book.v1.json" : {
2017 title : "Book"
2118 } ,
19+ "http://marc.stoplight-local.com:8080/api/v1/projects/marc/my-project/nodes/models/Street.v1.json" : {
20+ title : "Book"
21+ } ,
2222 } ) ;
2323
24- const model = {
24+ model = {
2525 properties : {
2626 id : {
2727 type : "string"
2828 } ,
2929 book : {
3030 $ref : "http://jakub.stoplight-local.com:8080/api/v1/projects/jakub/my-project/nodes/reference/Book.v1.json"
3131 } ,
32+ street : {
33+ $ref : "http://marc.stoplight-local.com:8080/api/v1/projects/marc/my-project/nodes/models/Street.v1.json"
34+ } ,
3235 }
3336 } ;
37+ } ) ;
38+
39+
40+ it ( "given explicit endpointUrl, should recognize platform references pointing at that entity" , async ( ) => {
41+ let defaults = createStoplightDefaults ( {
42+ cwd,
43+ endpointUrl : "http://jakub.stoplight-local.com:8080/api/v1/projects/jakub/my-project/nodes" ,
44+ } ) ;
3445
3546 let parser = new $RefParser ( ) ;
3647
@@ -51,6 +62,44 @@ describe("Stoplight-specific defaults", () => {
5162 } ,
5263 id : {
5364 type : "string"
65+ } ,
66+ street : {
67+ title : "Book"
68+ }
69+ }
70+ } ) ;
71+ } ) ;
72+
73+ it ( "given no explicit endpointUrl, should recognize platform references pointing at any Stoplight-compatible entity" , async ( ) => {
74+ let defaults = createStoplightDefaults ( {
75+ cwd,
76+ } ) ;
77+
78+ let parser = new $RefParser ( ) ;
79+
80+ const schema = await parser . bundle ( __dirname , model , {
81+ bundle : defaults . json_schema ,
82+ } ) ;
83+
84+ expect ( schema ) . to . equal ( parser . schema ) ;
85+ expect ( schema ) . to . deep . equal ( {
86+ definitions : {
87+ "Book.v1" : {
88+ title : "Book"
89+ } ,
90+ "Street.v1" : {
91+ title : "Book"
92+ }
93+ } ,
94+ properties : {
95+ book : {
96+ $ref : "#/definitions/Book.v1"
97+ } ,
98+ id : {
99+ type : "string"
100+ } ,
101+ street : {
102+ $ref : "#/definitions/Street.v1"
54103 }
55104 }
56105 } ) ;
0 commit comments