@@ -264,22 +264,7 @@ describe('json-refs API', function () {
264
264
name : testTypesDocument . definitions . String
265
265
}
266
266
} ;
267
- var expectedRelativeValue = {
268
- name : testNestedDocument . name ,
269
- child : {
270
- name : testNestedDocument1 . name ,
271
- ancestor : {
272
- name : testDocument1 . name ,
273
- nested : testDocument1 . nested ,
274
- local : testDocument1 . name ,
275
- missing : testDocument1 . missing
276
- } ,
277
- local : testNestedDocument1 . name ,
278
- missing : testNestedDocument1 . missing
279
- } ,
280
- local : testNestedDocument . name ,
281
- missing : testNestedDocument . missing
282
- } ;
267
+ var expectedRelativeValue ;
283
268
var expectedValidResolveRefs ;
284
269
var expectedFullyResolved ;
285
270
var remotePkgJson ;
@@ -288,6 +273,23 @@ describe('json-refs API', function () {
288
273
JsonRefs . findRefsAt ( 'https://rawgit.com/whitlockjc/json-refs/master/package.json' )
289
274
. then ( function ( refs ) {
290
275
remotePkgJson = refs . value ;
276
+ expectedRelativeValue = {
277
+ name : testNestedDocument . name ,
278
+ child : {
279
+ name : testNestedDocument1 . name ,
280
+ ancestor : {
281
+ name : testDocument1 . name ,
282
+ nested : testDocument1 . nested ,
283
+ local : testDocument1 . name ,
284
+ missing : testDocument1 . missing
285
+ } ,
286
+ local : testNestedDocument1 . name ,
287
+ missing : testNestedDocument1 . missing
288
+ } ,
289
+ local : testNestedDocument . name ,
290
+ missing : testNestedDocument . missing ,
291
+ remote : remotePkgJson
292
+ } ;
291
293
expectedValidResolveRefs = {
292
294
'#/local' : {
293
295
def : testDocument . local ,
@@ -527,6 +529,14 @@ describe('json-refs API', function () {
527
529
error : new Error ( 'JSON Pointer points to missing location: #/some/missing/path' ) ,
528
530
missing : true
529
531
} ,
532
+ '#/remote/relative/remote' : {
533
+ def : testNestedDocument . remote ,
534
+ fqURI : testNestedDocument . remote . $ref ,
535
+ uri : testNestedDocument . remote . $ref ,
536
+ uriDetails : URI . parse ( testNestedDocument . remote . $ref ) ,
537
+ type : 'remote' ,
538
+ value : expectedRelativeValue . remote
539
+ } ,
530
540
'#/definitions/Person/properties/name' : {
531
541
def : testDocument . definitions . Person . properties . name ,
532
542
fqURI : testDocument . definitions . Person . properties . name . $ref ,
@@ -1349,7 +1359,8 @@ describe('json-refs API', function () {
1349
1359
name : testNestedDocument . name ,
1350
1360
child : expectedRelativeValue . child ,
1351
1361
local : testNestedDocument . name ,
1352
- missing : testNestedDocument . missing
1362
+ missing : testNestedDocument . missing ,
1363
+ remote : expectedRelativeValue . remote
1353
1364
} ,
1354
1365
} ,
1355
1366
'#/remote/relative/child' : {
@@ -1427,6 +1438,14 @@ describe('json-refs API', function () {
1427
1438
type : 'local' ,
1428
1439
error : new Error ( 'JSON Pointer points to missing location: #/some/missing/path' ) ,
1429
1440
missing : true
1441
+ } ,
1442
+ '#/remote/relative/remote' : {
1443
+ def : testNestedDocument . remote ,
1444
+ fqURI : testNestedDocument . remote . $ref ,
1445
+ uri : testNestedDocument . remote . $ref ,
1446
+ uriDetails : URI . parse ( testNestedDocument . remote . $ref ) ,
1447
+ type : 'remote' ,
1448
+ value : expectedRelativeValue . remote
1430
1449
}
1431
1450
} ) ;
1432
1451
} )
@@ -1542,6 +1561,20 @@ describe('json-refs API', function () {
1542
1561
} ) ;
1543
1562
1544
1563
describe ( 'issues' , function ( ) {
1564
+ describe ( 'Issue #154' , function ( ) {
1565
+ it ( 'should not resolve remote references contained by relative references when options.filter does not indicate it' , function ( done ) {
1566
+ JsonRefs . resolveRefs ( testDocument , {
1567
+ filter : [ 'relative' ] ,
1568
+ loaderOptions : {
1569
+ processContent : yamlContentProcessor
1570
+ } ,
1571
+ location : testDocumentLocation
1572
+ } ) . then ( function ( res ) {
1573
+ assert . deepEqual ( res . resolved . remote . relative . remote , testNestedDocument . remote ) ;
1574
+ } )
1575
+ . then ( done , done ) ;
1576
+ } ) ;
1577
+ } ) ;
1545
1578
describe ( 'Issue #135' , function ( ) {
1546
1579
it ( 'should handle multi-document circular references' , function ( done ) {
1547
1580
JsonRefs . resolveRefsAt ( path . join ( typeof window === 'undefined' ?
0 commit comments