@@ -205,6 +205,63 @@ describe('resolve', () => {
205205 expect ( key ) . toBe ( 'bar' )
206206 expect ( target ) . toBe ( root [ key ] )
207207 } )
208+
209+ it ( 'should prioritize direct property over piercing' , ( ) => {
210+ const object = {
211+ 'foo-bar' : 'direct' ,
212+ foo : { bar : 'pierced' } ,
213+ }
214+ const { root, key, target } = resolve ( object , 'foo-bar' )
215+
216+ expect ( root ) . toBe ( object )
217+ expect ( key ) . toBe ( 'foo-bar' )
218+ expect ( target ) . toBe ( 'direct' )
219+ } )
220+
221+ it ( 'should handle undefined direct property values' , ( ) => {
222+ const object = { 'foo-bar' : undefined }
223+ const { root, key, target } = resolve ( object , 'foo-bar' )
224+
225+ expect ( root ) . toBe ( object )
226+ expect ( key ) . toBe ( 'foo-bar' )
227+ expect ( target ) . toBe ( undefined )
228+ } )
229+
230+ it ( 'should handle null direct property values' , ( ) => {
231+ const object = { 'foo-bar' : null }
232+ const { root, key, target } = resolve ( object , 'foo-bar' )
233+
234+ expect ( root ) . toBe ( object )
235+ expect ( key ) . toBe ( 'foo-bar' )
236+ expect ( target ) . toBe ( null )
237+ } )
238+
239+ it ( 'should return non-object as root when piercing fails due to non-object intermediate' , ( ) => {
240+ const object = { foo : 'not-an-object' }
241+ const { root, key, target } = resolve ( object , 'foo-bar' )
242+
243+ expect ( root ) . toBe ( 'not-an-object' )
244+ expect ( key ) . toBe ( 'bar' )
245+ expect ( target ) . toBe ( undefined )
246+ } )
247+
248+ it ( 'should return null as root when piercing fails due to null intermediate' , ( ) => {
249+ const object = { foo : null }
250+ const { root, key, target } = resolve ( object , 'foo-bar' )
251+
252+ expect ( root ) . toBe ( null )
253+ expect ( key ) . toBe ( 'bar' )
254+ expect ( target ) . toBe ( undefined )
255+ } )
256+
257+ it ( 'should handle non-dashed keys normally' , ( ) => {
258+ const object = { foo : 'value' }
259+ const { root, key, target } = resolve ( object , 'foo' )
260+
261+ expect ( root ) . toBe ( object )
262+ expect ( key ) . toBe ( 'foo' )
263+ expect ( target ) . toBe ( 'value' )
264+ } )
208265} )
209266
210267describe ( 'attach / detach' , ( ) => {
@@ -311,6 +368,19 @@ describe('applyProps', () => {
311368 expect ( ( ) => applyProps ( target , { } ) ) . not . toThrow ( )
312369 } )
313370
371+ it ( 'should not throw when applying unknown props' , ( ) => {
372+ const target = new THREE . Object3D ( )
373+ applyProps ( target , { } )
374+ expect ( ( ) => applyProps ( target , { [ 'foo-bar' ] : 1 } ) ) . not . toThrow ( )
375+ expect ( ( target as any ) [ 'foo-bar' ] ) . toBe ( undefined )
376+ } )
377+
378+ it ( 'should throw when applying unknown props due to non-object intermediate' , ( ) => {
379+ const target = new THREE . Object3D ( )
380+ applyProps ( target , { foo : 1 } )
381+ expect ( ( ) => applyProps ( target , { [ 'foo-bar' ] : 1 } ) ) . toThrow ( )
382+ } )
383+
314384 it ( 'should filter reserved props without accessing them' , ( ) => {
315385 const get = jest . fn ( )
316386 const set = jest . fn ( )
0 commit comments