File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,77 @@ describe('bundleTargetPath()', () => {
6363 } ) ;
6464 } ) ;
6565
66+ it ( 'should include falsy values' , ( ) => {
67+ const document = {
68+ definitions : {
69+ user : {
70+ id : {
71+ $ref : '#/definitions/id' ,
72+ } ,
73+ address : {
74+ $ref : '#/definitions/address' ,
75+ } ,
76+ } ,
77+ address : {
78+ street : {
79+ $ref : '#/definitions/street' ,
80+ } ,
81+ user : {
82+ $ref : '#/definitions/user' ,
83+ } ,
84+ } ,
85+ card : {
86+ zip : '20815' ,
87+ } ,
88+ street : null ,
89+ id : 0 ,
90+ } ,
91+ __target__ : {
92+ entity : {
93+ $ref : '#/definitions/user' ,
94+ } ,
95+ } ,
96+ } ;
97+
98+ const clone = cloneDeep ( document ) ;
99+
100+ const result = bundleTarget ( {
101+ document : clone ,
102+ path : '#/__target__' ,
103+ } ) ;
104+
105+ // Do not mutate document
106+ expect ( clone ) . toEqual ( document ) ;
107+
108+ expect ( result ) . toEqual ( {
109+ entity : {
110+ $ref : `#/${ BUNDLE_ROOT } /definitions/user` ,
111+ } ,
112+ [ BUNDLE_ROOT ] : {
113+ definitions : {
114+ user : {
115+ id : {
116+ $ref : `#/${ BUNDLE_ROOT } /definitions/id` ,
117+ } ,
118+ address : {
119+ $ref : `#/${ BUNDLE_ROOT } /definitions/address` ,
120+ } ,
121+ } ,
122+ address : {
123+ street : {
124+ $ref : `#/${ BUNDLE_ROOT } /definitions/street` ,
125+ } ,
126+ user : {
127+ $ref : `#/${ BUNDLE_ROOT } /definitions/user` ,
128+ } ,
129+ } ,
130+ id : 0 ,
131+ street : null ,
132+ } ,
133+ } ,
134+ } ) ;
135+ } ) ;
136+
66137 it ( 'should not throw erorr' , ( ) => {
67138 const document = {
68139 definitions : {
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ const _bundle = (
5252 if ( ! _path || ! inventoryPath || ! inventoryRef ) return ;
5353
5454 const bundled$Ref = get ( document , _path ) ;
55- if ( bundled$Ref ) {
55+ if ( bundled$Ref !== void 0 ) {
5656 const pathProcessed = [ ] ;
5757
5858 bundledRefInventory [ $ref ] = inventoryRef ;
You can’t perform that action at this time.
0 commit comments