@@ -33,43 +33,57 @@ describe("When executed in the context of root directory", () => {
3333
3434 it ( "should parse successfully from an absolute path" , async ( ) => {
3535 let parser = new $RefParser ( ) ;
36- const schema = await parser . parse ( path . abs ( "specs/absolute-root/empty-object.json " ) ) ;
36+ const schema = await parser . parse ( path . abs ( "specs/absolute-root/absolute-root.yaml " ) ) ;
3737 expect ( schema ) . to . equal ( parser . schema ) ;
38- expect ( schema ) . to . deep . equal ( parsedSchema ) ;
39- expect ( parser . $refs . paths ( ) ) . to . deep . equal ( [ path . abs ( "specs/absolute-root/empty-object.json" ) ] ) ;
38+ expect ( schema ) . to . deep . equal ( parsedSchema . schema ) ;
39+ expect ( parser . $refs . paths ( ) ) . to . deep . equal ( [
40+ path . abs ( "specs/absolute-root/absolute-root.yaml" )
41+ ] ) ;
4042 } ) ;
4143
42-
4344 it ( "should parse successfully from a url" , async ( ) => {
4445 let parser = new $RefParser ( ) ;
45- const schema = await parser . parse ( path . url ( "specs/absolute-root/empty-object.json " ) ) ;
46+ const schema = await parser . parse ( path . url ( "specs/absolute-root/absolute-root.yaml " ) ) ;
4647 expect ( schema ) . to . equal ( parser . schema ) ;
47- expect ( schema ) . to . deep . equal ( parsedSchema ) ;
48- expect ( parser . $refs . paths ( ) ) . to . deep . equal ( [ path . url ( "specs/absolute-root/empty-object.json " ) ] ) ;
48+ expect ( schema ) . to . deep . equal ( parsedSchema . schema ) ;
49+ expect ( parser . $refs . paths ( ) ) . to . deep . equal ( [ path . url ( "specs/absolute-root/absolute-root.yaml " ) ] ) ;
4950 } ) ;
5051
5152 it ( "should resolve successfully from an absolute path" , helper . testResolve (
52- path . abs ( "specs/absolute-root/empty-object.json" ) ,
53- path . abs ( "specs/absolute-root/empty-object.json" ) , parsedSchema ,
53+ path . abs ( "specs/absolute-root/absolute-root.yaml" ) ,
54+ path . abs ( "specs/absolute-root/absolute-root.yaml" ) , parsedSchema . schema ,
55+ path . abs ( "specs/absolute-root/definitions/definitions.json" ) , parsedSchema . definitions ,
56+ path . abs ( "specs/absolute-root/definitions/name.yaml" ) , parsedSchema . name ,
57+ path . abs ( "specs/absolute-root/definitions/required-string.yaml" ) , parsedSchema . requiredString
5458 ) ) ;
5559
5660 it ( "should resolve successfully from a url" , helper . testResolve (
57- path . url ( "specs/absolute-root/empty-object.json" ) ,
58- path . url ( "specs/absolute-root/empty-object.json" ) , parsedSchema ,
61+ path . url ( "specs/absolute-root/absolute-root.yaml" ) ,
62+ path . url ( "specs/absolute-root/absolute-root.yaml" ) , parsedSchema . schema ,
63+ path . url ( "specs/absolute-root/definitions/definitions.json" ) , parsedSchema . definitions ,
64+ path . url ( "specs/absolute-root/definitions/name.yaml" ) , parsedSchema . name ,
65+ path . url ( "specs/absolute-root/definitions/required-string.yaml" ) , parsedSchema . requiredString
5966 ) ) ;
6067
6168 it ( "should dereference successfully" , async ( ) => {
6269 let parser = new $RefParser ( ) ;
63- const schema = await parser . dereference ( path . abs ( "specs/absolute-root/empty-object.json " ) ) ;
70+ const schema = await parser . dereference ( path . abs ( "specs/absolute-root/absolute-root.yaml " ) ) ;
6471 expect ( schema ) . to . equal ( parser . schema ) ;
6572 expect ( schema ) . to . deep . equal ( dereferencedSchema ) ;
73+ // Reference equality
74+ expect ( schema . properties . name ) . to . equal ( schema . definitions . name ) ;
75+ expect ( schema . definitions [ "required string" ] )
76+ . to . equal ( schema . definitions . name . properties . first )
77+ . to . equal ( schema . definitions . name . properties . last )
78+ . to . equal ( schema . properties . name . properties . first )
79+ . to . equal ( schema . properties . name . properties . last ) ;
6680 // The "circular" flag should NOT be set
6781 expect ( parser . $refs . circular ) . to . equal ( false ) ;
6882 } ) ;
6983
7084 it ( "should bundle successfully" , async ( ) => {
7185 let parser = new $RefParser ( ) ;
72- const schema = await parser . bundle ( path . abs ( "specs/absolute-root/empty-object.json " ) ) ;
86+ const schema = await parser . bundle ( path . abs ( "specs/absolute-root/absolute-root.yaml " ) ) ;
7387 expect ( schema ) . to . equal ( parser . schema ) ;
7488 expect ( schema ) . to . deep . equal ( bundledSchema ) ;
7589 } ) ;
0 commit comments