@@ -30,7 +30,7 @@ describe('set', () => {
3030 expect ( result ) . toEqual ( { a : { b : 1 } } ) ;
3131 } ) ;
3232
33- it ( 'should set a value on an object with nested path' , ( ) => {
33+ it ( 'should set a value on an object with deeply nested path' , ( ) => {
3434 const result = set < { a : { b : { c : { d : number } } } } > ( { } as { a : { b : { c : { d : number } } } } , 'a.b.c.d' , 1 ) ;
3535 expect ( result ) . toEqual ( { a : { b : { c : { d : 1 } } } } ) ;
3636 } ) ;
@@ -44,18 +44,19 @@ describe('set', () => {
4444 expect ( result [ 0 ] ) . toEqual ( 1 ) ;
4545 } ) ;
4646
47- it ( 'should set a value on an array with nested path' , ( ) => {
47+ it ( 'should set a value on an array with nested path of depth 2 ' , ( ) => {
4848 const result = set < number [ ] [ ] > ( [ ] as number [ ] [ ] , '0.0' , 1 ) ;
4949 expect ( result ) . toEqual ( [ [ 1 ] ] ) ;
5050 expect ( result [ 0 ] [ 0 ] ) . toEqual ( 1 ) ;
5151 } ) ;
5252
53- it ( 'should set a value on an array with nested path' , ( ) => {
53+ it ( 'should set a value on an array with nested path of depth 3 ' , ( ) => {
5454 const result = set < number [ ] [ ] [ ] > ( [ ] , '0.0.0' , 1 ) ;
5555 expect ( result ) . toEqual ( [ [ [ 1 ] ] ] ) ;
5656 expect ( result [ 0 ] [ 0 ] [ 0 ] ) . toEqual ( 1 ) ;
5757 } ) ;
58- it ( 'should set a value on an array with nested path' , ( ) => {
58+
59+ it ( 'should set a value on an existing array at a specific index' , ( ) => {
5960 const arr = [ 1 , 2 , 3 ] ;
6061 set ( arr , 1 , 4 ) ;
6162 expect ( arr ) . toEqual ( [ 1 , 4 , 3 ] ) ;
@@ -65,25 +66,25 @@ describe('set', () => {
6566 //--------------------------------------------------------------------------------
6667 // object and array
6768 //--------------------------------------------------------------------------------
68- it ( 'should set a value on an object and array ' , ( ) => {
69+ it ( 'should set a value on an array containing an object ' , ( ) => {
6970 const result = set < Array < { a : number } > > ( [ ] as Array < { a : number } > , '0.a' , 1 ) ;
7071 expect ( result ) . toEqual ( [ { a : 1 } ] ) ;
7172 expect ( result [ 0 ] . a ) . toEqual ( 1 ) ;
7273 } ) ;
7374
74- it ( 'should set a value on an object and array' , ( ) => {
75+ it ( 'should set a value on an object containing an array' , ( ) => {
7576 const result = set < { a : number [ ] } > ( { } as { a : number [ ] } , 'a.0' , 1 ) ;
7677 expect ( result ) . toEqual ( { a : [ 1 ] } ) ;
7778 expect ( result . a [ 0 ] ) . toEqual ( 1 ) ;
7879 } ) ;
7980
80- it ( 'should set a value on an object and array ' , ( ) => {
81+ it ( 'should set a value on an object containing nested arrays ' , ( ) => {
8182 const result = set < { a : number [ ] [ ] } > ( { } as { a : number [ ] [ ] } , 'a.0.0' , 1 ) ;
8283 expect ( result ) . toEqual ( { a : [ [ 1 ] ] } ) ;
8384 expect ( result . a [ 0 ] [ 0 ] ) . toEqual ( 1 ) ;
8485 } ) ;
8586
86- it ( 'should set a value on an object and array ' , ( ) => {
87+ it ( 'should set a value on an object containing deeply nested arrays with bracket notation ' , ( ) => {
8788 const result = set < { a : number [ ] [ ] [ ] } > ( { } as { a : number [ ] [ ] [ ] } , 'a[0][0][0]' , 1 ) ;
8889 expect ( result ) . toEqual ( { a : [ [ [ 1 ] ] ] } ) ;
8990 expect ( result . a [ 0 ] [ 0 ] [ 0 ] ) . toEqual ( 1 ) ;
0 commit comments