1
1
'use strict' ;
2
2
var expect = require ( 'chai' ) . expect ,
3
- objectPath = require ( './index.js' ) ;
3
+ objectPath = require ( './index.js' ) ;
4
4
5
5
6
6
function getTestObj ( ) {
@@ -161,34 +161,34 @@ describe('set', function() {
161
161
it ( 'should set value under shallow object' , function ( ) {
162
162
var obj = getTestObj ( ) ;
163
163
objectPath . set ( obj , 'c' , { m : 'o' } ) ;
164
- expect ( obj ) . to . have . deep . property ( 'c.m' , 'o' ) ;
164
+ expect ( obj ) . to . include . nested . property ( 'c.m' , 'o' ) ;
165
165
obj = getTestObj ( ) ;
166
166
objectPath . set ( obj , [ 'c' ] , { m : 'o' } ) ;
167
- expect ( obj ) . to . have . deep . property ( 'c.m' , 'o' ) ;
167
+ expect ( obj ) . to . include . nested . property ( 'c.m' , 'o' ) ;
168
168
} ) ;
169
169
170
170
it ( 'should set value using number path' , function ( ) {
171
171
var obj = getTestObj ( ) ;
172
172
objectPath . set ( obj . b . d , 0 , 'o' ) ;
173
- expect ( obj ) . to . have . deep . property ( 'b.d.0' , 'o' ) ;
173
+ expect ( obj ) . to . have . nested . property ( 'b.d.0' , 'o' ) ;
174
174
} ) ;
175
175
176
176
it ( 'should set value under deep object' , function ( ) {
177
177
var obj = getTestObj ( ) ;
178
178
objectPath . set ( obj , 'b.c' , 'o' ) ;
179
- expect ( obj ) . to . have . deep . property ( 'b.c' , 'o' ) ;
179
+ expect ( obj ) . to . have . nested . property ( 'b.c' , 'o' ) ;
180
180
obj = getTestObj ( ) ;
181
181
objectPath . set ( obj , [ 'b' , 'c' ] , 'o' ) ;
182
- expect ( obj ) . to . have . deep . property ( 'b.c' , 'o' ) ;
182
+ expect ( obj ) . to . have . nested . property ( 'b.c' , 'o' ) ;
183
183
} ) ;
184
184
185
185
it ( 'should set value under array' , function ( ) {
186
186
var obj = getTestObj ( ) ;
187
187
objectPath . set ( obj , 'b.e.1.g' , 'f' ) ;
188
- expect ( obj ) . to . have . deep . property ( 'b.e.1.g' , 'f' ) ;
188
+ expect ( obj ) . to . have . nested . property ( 'b.e.1.g' , 'f' ) ;
189
189
obj = getTestObj ( ) ;
190
190
objectPath . set ( obj , [ 'b' , 'e' , 1 , 'g' ] , 'f' ) ;
191
- expect ( obj ) . to . have . deep . property ( 'b.e.1.g' , 'f' ) ;
191
+ expect ( obj ) . to . have . nested . property ( 'b.e.1.g' , 'f' ) ;
192
192
193
193
obj = { }
194
194
objectPath . set ( obj , 'b.0' , 'a' ) ;
@@ -199,32 +199,32 @@ describe('set', function() {
199
199
it ( 'should create intermediate objects' , function ( ) {
200
200
var obj = getTestObj ( ) ;
201
201
objectPath . set ( obj , 'c.d.e.f' , 'l' ) ;
202
- expect ( obj ) . to . have . deep . property ( 'c.d.e.f' , 'l' ) ;
202
+ expect ( obj ) . to . have . nested . property ( 'c.d.e.f' , 'l' ) ;
203
203
obj = getTestObj ( ) ;
204
204
objectPath . set ( obj , [ 'c' , 'd' , 'e' , 'f' ] , 'l' ) ;
205
- expect ( obj ) . to . have . deep . property ( 'c.d.e.f' , 'l' ) ;
205
+ expect ( obj ) . to . have . nested . property ( 'c.d.e.f' , 'l' ) ;
206
206
} ) ;
207
207
208
208
it ( 'should create intermediate arrays' , function ( ) {
209
209
var obj = getTestObj ( ) ;
210
210
objectPath . set ( obj , 'c.0.1.m' , 'l' ) ;
211
211
expect ( obj . c ) . to . be . an ( 'array' ) ;
212
212
expect ( obj . c [ 0 ] ) . to . be . an ( 'array' ) ;
213
- expect ( obj ) . to . have . deep . property ( 'c.0.1.m' , 'l' ) ;
213
+ expect ( obj ) . to . have . nested . property ( 'c.0.1.m' , 'l' ) ;
214
214
obj = getTestObj ( ) ;
215
215
objectPath . set ( obj , [ 'c' , '0' , 1 , 'm' ] , 'l' ) ;
216
216
expect ( obj . c ) . to . be . an ( 'object' ) ;
217
217
expect ( obj . c [ 0 ] ) . to . be . an ( 'array' ) ;
218
- expect ( obj ) . to . have . deep . property ( 'c.0.1.m' , 'l' ) ;
218
+ expect ( obj ) . to . have . nested . property ( 'c.0.1.m' , 'l' ) ;
219
219
} ) ;
220
220
221
221
it ( 'should set value under integer-like key' , function ( ) {
222
222
var obj = getTestObj ( ) ;
223
223
objectPath . set ( obj , '1a' , 'foo' ) ;
224
- expect ( obj ) . to . have . deep . property ( '1a' , 'foo' ) ;
224
+ expect ( obj ) . to . have . nested . property ( '1a' , 'foo' ) ;
225
225
obj = getTestObj ( ) ;
226
226
objectPath . set ( obj , [ '1a' ] , 'foo' ) ;
227
- expect ( obj ) . to . have . deep . property ( '1a' , 'foo' ) ;
227
+ expect ( obj ) . to . have . nested . property ( '1a' , 'foo' ) ;
228
228
} ) ;
229
229
230
230
it ( 'should set value under empty array' , function ( ) {
@@ -242,9 +242,9 @@ describe('push', function() {
242
242
it ( 'should push value to existing array using unicode key' , function ( ) {
243
243
var obj = getTestObj ( ) ;
244
244
objectPath . push ( obj , 'b.\u1290c' , 'l' ) ;
245
- expect ( obj ) . to . have . deep . property ( 'b.\u1290c.0' , 'l' ) ;
245
+ expect ( obj ) . to . have . nested . property ( 'b.\u1290c.0' , 'l' ) ;
246
246
objectPath . push ( obj , [ 'b' , '\u1290c' ] , 'l' ) ;
247
- expect ( obj ) . to . have . deep . property ( 'b.\u1290c.1' , 'l' ) ;
247
+ expect ( obj ) . to . have . nested . property ( 'b.\u1290c.1' , 'l' ) ;
248
248
} ) ;
249
249
250
250
it ( 'should push value to existing array using dot key' , function ( ) {
@@ -256,25 +256,25 @@ describe('push', function() {
256
256
it ( 'should push value to existing array' , function ( ) {
257
257
var obj = getTestObj ( ) ;
258
258
objectPath . push ( obj , 'b.c' , 'l' ) ;
259
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'l' ) ;
259
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'l' ) ;
260
260
obj = getTestObj ( ) ;
261
261
objectPath . push ( obj , [ 'b' , 'c' ] , 'l' ) ;
262
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'l' ) ;
262
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'l' ) ;
263
263
} ) ;
264
264
265
265
it ( 'should push value to new array' , function ( ) {
266
266
var obj = getTestObj ( ) ;
267
267
objectPath . push ( obj , 'b.h' , 'l' ) ;
268
- expect ( obj ) . to . have . deep . property ( 'b.h.0' , 'l' ) ;
268
+ expect ( obj ) . to . have . nested . property ( 'b.h.0' , 'l' ) ;
269
269
obj = getTestObj ( ) ;
270
270
objectPath . push ( obj , [ 'b' , 'h' ] , 'l' ) ;
271
- expect ( obj ) . to . have . deep . property ( 'b.h.0' , 'l' ) ;
271
+ expect ( obj ) . to . have . nested . property ( 'b.h.0' , 'l' ) ;
272
272
} ) ;
273
273
274
274
it ( 'should push value to existing array using number path' , function ( ) {
275
275
var obj = getTestObj ( ) ;
276
276
objectPath . push ( obj . b . e , 0 , 'l' ) ;
277
- expect ( obj ) . to . have . deep . property ( 'b.e.0.0' , 'l' ) ;
277
+ expect ( obj ) . to . have . nested . property ( 'b.e.0.0' , 'l' ) ;
278
278
} ) ;
279
279
280
280
} ) ;
@@ -285,13 +285,13 @@ describe('ensureExists', function() {
285
285
var obj = getTestObj ( ) ;
286
286
var oldVal = objectPath . ensureExists ( obj , 'b.g.1.l' , 'test' ) ;
287
287
expect ( oldVal ) . to . not . exist ;
288
- expect ( obj ) . to . have . deep . property ( 'b.g.1.l' , 'test' ) ;
288
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.l' , 'test' ) ;
289
289
oldVal = objectPath . ensureExists ( obj , 'b.g.1.l' , 'test1' ) ;
290
290
expect ( oldVal ) . to . be . equal ( 'test' ) ;
291
- expect ( obj ) . to . have . deep . property ( 'b.g.1.l' , 'test' ) ;
291
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.l' , 'test' ) ;
292
292
oldVal = objectPath . ensureExists ( obj , 'b.\u8210' , 'ok' ) ;
293
293
expect ( oldVal ) . to . not . exist ;
294
- expect ( obj ) . to . have . deep . property ( 'b.\u8210' , 'ok' ) ;
294
+ expect ( obj ) . to . have . nested . property ( 'b.\u8210' , 'ok' ) ;
295
295
oldVal = objectPath . ensureExists ( obj , [ 'b' , 'dot.dot' ] , 'ok' ) ;
296
296
expect ( oldVal ) . to . not . exist ;
297
297
expect ( objectPath . get ( obj , [ 'b' , 'dot.dot' ] ) ) . to . be . equal ( 'ok' ) ;
@@ -497,30 +497,30 @@ describe('del', function(){
497
497
objectPath . set ( obj , 'b.\ubeef' , 'test' ) ;
498
498
objectPath . set ( obj , [ 'b' , 'dot.dot' ] , 'test' ) ;
499
499
500
- expect ( obj ) . to . have . deep . property ( 'b.g.1.0' , 'test' ) ;
501
- expect ( obj ) . to . have . deep . property ( 'b.g.1.1' , 'test' ) ;
502
- expect ( obj ) . to . have . deep . property ( 'b.h.az' , 'test' ) ;
503
- expect ( obj ) . to . have . deep . property ( 'b.\ubeef' , 'test' ) ;
500
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.0' , 'test' ) ;
501
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.1' , 'test' ) ;
502
+ expect ( obj ) . to . have . nested . property ( 'b.h.az' , 'test' ) ;
503
+ expect ( obj ) . to . have . nested . property ( 'b.\ubeef' , 'test' ) ;
504
504
505
505
objectPath . del ( obj , 'b.h.az' ) ;
506
- expect ( obj ) . to . not . have . deep . property ( 'b.h.az' ) ;
507
- expect ( obj ) . to . have . deep . property ( 'b.h' ) ;
506
+ expect ( obj ) . to . not . have . nested . property ( 'b.h.az' ) ;
507
+ expect ( obj ) . to . have . nested . property ( 'b.h' ) ;
508
508
509
509
objectPath . del ( obj , 'b.g.1.1' ) ;
510
- expect ( obj ) . to . not . have . deep . property ( 'b.g.1.1' ) ;
511
- expect ( obj ) . to . have . deep . property ( 'b.g.1.0' , 'test' ) ;
510
+ expect ( obj ) . to . not . have . nested . property ( 'b.g.1.1' ) ;
511
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.0' , 'test' ) ;
512
512
513
513
objectPath . del ( obj , 'b.\ubeef' ) ;
514
- expect ( obj ) . to . not . have . deep . property ( 'b.\ubeef' ) ;
514
+ expect ( obj ) . to . not . have . nested . property ( 'b.\ubeef' ) ;
515
515
516
516
objectPath . del ( obj , [ 'b' , 'dot.dot' ] ) ;
517
517
expect ( objectPath . get ( obj , [ 'b' , 'dot.dot' ] ) ) . to . be . equal ( void 0 ) ;
518
518
519
519
objectPath . del ( obj , [ 'b' , 'g' , '1' , '0' ] ) ;
520
- expect ( obj ) . to . not . have . deep . property ( 'b.g.1.0' ) ;
521
- expect ( obj ) . to . have . deep . property ( 'b.g.1' ) ;
520
+ expect ( obj ) . to . not . have . nested . property ( 'b.g.1.0' ) ;
521
+ expect ( obj ) . to . have . nested . property ( 'b.g.1' ) ;
522
522
523
- expect ( objectPath . del ( obj , [ 'b' ] ) ) . to . not . have . deep . property ( 'b.g' ) ;
523
+ expect ( objectPath . del ( obj , [ 'b' ] ) ) . to . not . have . nested . property ( 'b.g' ) ;
524
524
expect ( obj ) . to . be . deep . equal ( { 'a' :'b' } ) ;
525
525
} ) ;
526
526
@@ -542,24 +542,24 @@ describe('insert', function(){
542
542
var obj = getTestObj ( ) ;
543
543
544
544
objectPath . insert ( obj , 'b.c' , 'asdf' ) ;
545
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'asdf' ) ;
546
- expect ( obj ) . to . not . have . deep . property ( 'b.c.1' ) ;
545
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'asdf' ) ;
546
+ expect ( obj ) . to . not . have . nested . property ( 'b.c.1' ) ;
547
547
} ) ;
548
548
549
549
it ( 'should create intermediary array' , function ( ) {
550
550
var obj = getTestObj ( ) ;
551
551
552
552
objectPath . insert ( obj , 'b.c.0' , 'asdf' ) ;
553
- expect ( obj ) . to . have . deep . property ( 'b.c.0.0' , 'asdf' ) ;
553
+ expect ( obj ) . to . have . nested . property ( 'b.c.0.0' , 'asdf' ) ;
554
554
} ) ;
555
555
556
556
it ( 'should insert in another index' , function ( ) {
557
557
var obj = getTestObj ( ) ;
558
558
559
559
objectPath . insert ( obj , 'b.d' , 'asdf' , 1 ) ;
560
- expect ( obj ) . to . have . deep . property ( 'b.d.1' , 'asdf' ) ;
561
- expect ( obj ) . to . have . deep . property ( 'b.d.0' , 'a' ) ;
562
- expect ( obj ) . to . have . deep . property ( 'b.d.2' , 'b' ) ;
560
+ expect ( obj ) . to . have . nested . property ( 'b.d.1' , 'asdf' ) ;
561
+ expect ( obj ) . to . have . nested . property ( 'b.d.0' , 'a' ) ;
562
+ expect ( obj ) . to . have . nested . property ( 'b.d.2' , 'b' ) ;
563
563
} ) ;
564
564
565
565
it ( 'should handle sparse array' , function ( ) {
@@ -681,33 +681,33 @@ describe('bind object', function () {
681
681
var obj = getTestObj ( ) ;
682
682
var model = objectPath ( obj ) ;
683
683
model . set ( 'c' , { m : 'o' } ) ;
684
- expect ( obj ) . to . have . deep . property ( 'c.m' , 'o' ) ;
684
+ expect ( obj ) . to . have . nested . property ( 'c.m' , 'o' ) ;
685
685
obj = getTestObj ( ) ;
686
686
model = objectPath ( obj ) ;
687
687
model . set ( [ 'c' ] , { m : 'o' } ) ;
688
- expect ( obj ) . to . have . deep . property ( 'c.m' , 'o' ) ;
688
+ expect ( obj ) . to . have . nested . property ( 'c.m' , 'o' ) ;
689
689
} ) ;
690
690
691
691
it ( 'should push value to existing array' , function ( ) {
692
692
var obj = getTestObj ( ) ;
693
693
var model = objectPath ( obj ) ;
694
694
model . push ( 'b.c' , 'l' ) ;
695
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'l' ) ;
695
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'l' ) ;
696
696
obj = getTestObj ( ) ;
697
697
model = objectPath ( obj ) ;
698
698
model . push ( [ 'b' , 'c' ] , 'l' ) ;
699
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'l' ) ;
699
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'l' ) ;
700
700
} ) ;
701
701
702
702
it ( 'should create the path if it does not exists' , function ( ) {
703
703
var obj = getTestObj ( ) ;
704
704
var model = objectPath ( obj ) ;
705
705
var oldVal = model . ensureExists ( 'b.g.1.l' , 'test' ) ;
706
706
expect ( oldVal ) . to . not . exist ;
707
- expect ( obj ) . to . have . deep . property ( 'b.g.1.l' , 'test' ) ;
707
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.l' , 'test' ) ;
708
708
oldVal = model . ensureExists ( 'b.g.1.l' , 'test1' ) ;
709
709
expect ( oldVal ) . to . be . equal ( 'test' ) ;
710
- expect ( obj ) . to . have . deep . property ( 'b.g.1.l' , 'test' ) ;
710
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.l' , 'test' ) ;
711
711
} ) ;
712
712
713
713
it ( 'should return the first non-undefined value' , function ( ) {
@@ -792,23 +792,23 @@ describe('bind object', function () {
792
792
model . set ( 'b.g.1.1' , 'test' ) ;
793
793
model . set ( 'b.h.az' , 'test' ) ;
794
794
795
- expect ( obj ) . to . have . deep . property ( 'b.g.1.0' , 'test' ) ;
796
- expect ( obj ) . to . have . deep . property ( 'b.g.1.1' , 'test' ) ;
797
- expect ( obj ) . to . have . deep . property ( 'b.h.az' , 'test' ) ;
795
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.0' , 'test' ) ;
796
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.1' , 'test' ) ;
797
+ expect ( obj ) . to . have . nested . property ( 'b.h.az' , 'test' ) ;
798
798
799
799
model . del ( 'b.h.az' ) ;
800
- expect ( obj ) . to . not . have . deep . property ( 'b.h.az' ) ;
801
- expect ( obj ) . to . have . deep . property ( 'b.h' ) ;
800
+ expect ( obj ) . to . not . have . nested . property ( 'b.h.az' ) ;
801
+ expect ( obj ) . to . have . nested . property ( 'b.h' ) ;
802
802
803
803
model . del ( 'b.g.1.1' ) ;
804
- expect ( obj ) . to . not . have . deep . property ( 'b.g.1.1' ) ;
805
- expect ( obj ) . to . have . deep . property ( 'b.g.1.0' , 'test' ) ;
804
+ expect ( obj ) . to . not . have . nested . property ( 'b.g.1.1' ) ;
805
+ expect ( obj ) . to . have . nested . property ( 'b.g.1.0' , 'test' ) ;
806
806
807
807
model . del ( [ 'b' , 'g' , '1' , '0' ] ) ;
808
- expect ( obj ) . to . not . have . deep . property ( 'b.g.1.0' ) ;
809
- expect ( obj ) . to . have . deep . property ( 'b.g.1' ) ;
808
+ expect ( obj ) . to . not . have . nested . property ( 'b.g.1.0' ) ;
809
+ expect ( obj ) . to . have . nested . property ( 'b.g.1' ) ;
810
810
811
- expect ( model . del ( [ 'b' ] ) ) . to . not . have . deep . property ( 'b.g' ) ;
811
+ expect ( model . del ( [ 'b' ] ) ) . to . not . have . nested . property ( 'b.g' ) ;
812
812
expect ( obj ) . to . be . deep . equal ( { 'a' :'b' } ) ;
813
813
} ) ;
814
814
@@ -817,8 +817,8 @@ describe('bind object', function () {
817
817
var model = objectPath ( obj ) ;
818
818
819
819
model . insert ( 'b.c' , 'asdf' ) ;
820
- expect ( obj ) . to . have . deep . property ( 'b.c.0' , 'asdf' ) ;
821
- expect ( obj ) . to . not . have . deep . property ( 'b.c.1' ) ;
820
+ expect ( obj ) . to . have . nested . property ( 'b.c.0' , 'asdf' ) ;
821
+ expect ( obj ) . to . not . have . nested . property ( 'b.c.1' ) ;
822
822
} ) ;
823
823
824
824
it ( 'should test under shallow object' , function ( ) {
0 commit comments