Skip to content

Commit d680fe7

Browse files
authoredMar 6, 2018
Merge pull request #92 from arunasank/hot-chai
Chai 4.1.2
2 parents 99d9d30 + ee0c79f commit d680fe7

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@mariocasciaro/benchpress": "^0.1.3",
18-
"chai": "^3.5.0",
18+
"chai": "^4.1.2",
1919
"coveralls": "^2.11.2",
2020
"istanbul": "^0.4.4",
2121
"mocha": "^2.2.4",

‎test.js

+60-60
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
var expect = require('chai').expect,
3-
objectPath = require('./index.js');
3+
objectPath = require('./index.js');
44

55

66
function getTestObj() {
@@ -161,34 +161,34 @@ describe('set', function() {
161161
it('should set value under shallow object', function() {
162162
var obj = getTestObj();
163163
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');
165165
obj = getTestObj();
166166
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');
168168
});
169169

170170
it('should set value using number path', function() {
171171
var obj = getTestObj();
172172
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');
174174
});
175175

176176
it('should set value under deep object', function() {
177177
var obj = getTestObj();
178178
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');
180180
obj = getTestObj();
181181
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');
183183
});
184184

185185
it('should set value under array', function() {
186186
var obj = getTestObj();
187187
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');
189189
obj = getTestObj();
190190
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');
192192

193193
obj = {}
194194
objectPath.set(obj, 'b.0', 'a');
@@ -199,32 +199,32 @@ describe('set', function() {
199199
it('should create intermediate objects', function() {
200200
var obj = getTestObj();
201201
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');
203203
obj = getTestObj();
204204
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');
206206
});
207207

208208
it('should create intermediate arrays', function() {
209209
var obj = getTestObj();
210210
objectPath.set(obj, 'c.0.1.m', 'l');
211211
expect(obj.c).to.be.an('array');
212212
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');
214214
obj = getTestObj();
215215
objectPath.set(obj, ['c','0', 1,'m'], 'l');
216216
expect(obj.c).to.be.an('object');
217217
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');
219219
});
220220

221221
it('should set value under integer-like key', function() {
222222
var obj = getTestObj();
223223
objectPath.set(obj, '1a', 'foo');
224-
expect(obj).to.have.deep.property('1a', 'foo');
224+
expect(obj).to.have.nested.property('1a', 'foo');
225225
obj = getTestObj();
226226
objectPath.set(obj, ['1a'], 'foo');
227-
expect(obj).to.have.deep.property('1a', 'foo');
227+
expect(obj).to.have.nested.property('1a', 'foo');
228228
});
229229

230230
it('should set value under empty array', function() {
@@ -242,9 +242,9 @@ describe('push', function() {
242242
it('should push value to existing array using unicode key', function() {
243243
var obj = getTestObj();
244244
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');
246246
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');
248248
});
249249

250250
it('should push value to existing array using dot key', function() {
@@ -256,25 +256,25 @@ describe('push', function() {
256256
it('should push value to existing array', function() {
257257
var obj = getTestObj();
258258
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');
260260
obj = getTestObj();
261261
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');
263263
});
264264

265265
it('should push value to new array', function() {
266266
var obj = getTestObj();
267267
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');
269269
obj = getTestObj();
270270
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');
272272
});
273273

274274
it('should push value to existing array using number path', function() {
275275
var obj = getTestObj();
276276
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');
278278
});
279279

280280
});
@@ -285,13 +285,13 @@ describe('ensureExists', function() {
285285
var obj = getTestObj();
286286
var oldVal = objectPath.ensureExists(obj, 'b.g.1.l', 'test');
287287
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');
289289
oldVal = objectPath.ensureExists(obj, 'b.g.1.l', 'test1');
290290
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');
292292
oldVal = objectPath.ensureExists(obj, 'b.\u8210', 'ok');
293293
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');
295295
oldVal = objectPath.ensureExists(obj, ['b','dot.dot'], 'ok');
296296
expect(oldVal).to.not.exist;
297297
expect(objectPath.get(obj, ['b','dot.dot'])).to.be.equal('ok');
@@ -497,30 +497,30 @@ describe('del', function(){
497497
objectPath.set(obj, 'b.\ubeef', 'test');
498498
objectPath.set(obj, ['b','dot.dot'], 'test');
499499

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');
504504

505505
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');
508508

509509
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');
512512

513513
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');
515515

516516
objectPath.del(obj, ['b','dot.dot']);
517517
expect(objectPath.get(obj, ['b','dot.dot'])).to.be.equal(void 0);
518518

519519
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');
522522

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');
524524
expect(obj).to.be.deep.equal({'a':'b'});
525525
});
526526

@@ -542,24 +542,24 @@ describe('insert', function(){
542542
var obj = getTestObj();
543543

544544
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');
547547
});
548548

549549
it('should create intermediary array', function(){
550550
var obj = getTestObj();
551551

552552
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');
554554
});
555555

556556
it('should insert in another index', function(){
557557
var obj = getTestObj();
558558

559559
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');
563563
});
564564

565565
it('should handle sparse array', function(){
@@ -681,33 +681,33 @@ describe('bind object', function () {
681681
var obj = getTestObj();
682682
var model = objectPath(obj);
683683
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');
685685
obj = getTestObj();
686686
model = objectPath(obj);
687687
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');
689689
});
690690

691691
it('should push value to existing array', function() {
692692
var obj = getTestObj();
693693
var model = objectPath(obj);
694694
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');
696696
obj = getTestObj();
697697
model = objectPath(obj);
698698
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');
700700
});
701701

702702
it('should create the path if it does not exists', function() {
703703
var obj = getTestObj();
704704
var model = objectPath(obj);
705705
var oldVal = model.ensureExists('b.g.1.l', 'test');
706706
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');
708708
oldVal = model.ensureExists('b.g.1.l', 'test1');
709709
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');
711711
});
712712

713713
it('should return the first non-undefined value', function(){
@@ -792,23 +792,23 @@ describe('bind object', function () {
792792
model.set('b.g.1.1', 'test');
793793
model.set('b.h.az', 'test');
794794

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');
798798

799799
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');
802802

803803
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');
806806

807807
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');
810810

811-
expect(model.del(['b'])).to.not.have.deep.property('b.g');
811+
expect(model.del(['b'])).to.not.have.nested.property('b.g');
812812
expect(obj).to.be.deep.equal({'a':'b'});
813813
});
814814

@@ -817,8 +817,8 @@ describe('bind object', function () {
817817
var model = objectPath(obj);
818818

819819
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');
822822
});
823823

824824
it('should test under shallow object', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.