Skip to content

Commit 84a7f3f

Browse files
committed
[tests] allow plugins extend total user correction
1 parent 171d598 commit 84a7f3f

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

test/3.api.write/2.write.app.sessions.js

+28-7
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ describe('Writing app sessions', function() {
226226
if (err) {
227227
return done(err);
228228
}
229-
res.text.should.eql('[{"_id":"users","u":1}]');
229+
var ob = JSON.parse(res.text);
230+
ob.should.have.length(1);
231+
ob[0].should.have.property('_id', 'users');
232+
ob[0].should.have.property('u', 1);
230233
done();
231234
});
232235
});
@@ -312,7 +315,10 @@ describe('Writing app sessions', function() {
312315
if (err) {
313316
return done(err);
314317
}
315-
res.text.should.eql('[{"_id":"users","u":1}]');
318+
var ob = JSON.parse(res.text);
319+
ob.should.have.length(1);
320+
ob[0].should.have.property('_id', 'users');
321+
ob[0].should.have.property('u', 1);
316322
done();
317323
});
318324
});
@@ -398,7 +404,10 @@ describe('Writing app sessions', function() {
398404
if (err) {
399405
return done(err);
400406
}
401-
res.text.should.eql('[{"_id":"users","u":2}]');
407+
var ob = JSON.parse(res.text);
408+
ob.should.have.length(1);
409+
ob[0].should.have.property('_id', 'users');
410+
ob[0].should.have.property('u', 2);
402411
done();
403412
});
404413
});
@@ -484,7 +493,10 @@ describe('Writing app sessions', function() {
484493
if (err) {
485494
return done(err);
486495
}
487-
res.text.should.eql('[{"_id":"users","u":2}]');
496+
var ob = JSON.parse(res.text);
497+
ob.should.have.length(1);
498+
ob[0].should.have.property('_id', 'users');
499+
ob[0].should.have.property('u', 2);
488500
done();
489501
});
490502
});
@@ -570,7 +582,10 @@ describe('Writing app sessions', function() {
570582
if (err) {
571583
return done(err);
572584
}
573-
res.text.should.eql('[{"_id":"users","u":2}]');
585+
var ob = JSON.parse(res.text);
586+
ob.should.have.length(1);
587+
ob[0].should.have.property('_id', 'users');
588+
ob[0].should.have.property('u', 2);
574589
done();
575590
});
576591
});
@@ -656,7 +671,10 @@ describe('Writing app sessions', function() {
656671
if (err) {
657672
return done(err);
658673
}
659-
res.text.should.eql('[{"_id":"users","u":2}]');
674+
var ob = JSON.parse(res.text);
675+
ob.should.have.length(1);
676+
ob[0].should.have.property('_id', 'users');
677+
ob[0].should.have.property('u', 2);
660678
done();
661679
});
662680
});
@@ -742,7 +760,10 @@ describe('Writing app sessions', function() {
742760
if (err) {
743761
return done(err);
744762
}
745-
res.text.should.eql('[{"_id":"users","u":2}]');
763+
var ob = JSON.parse(res.text);
764+
ob.should.have.length(1);
765+
ob[0].should.have.property('_id', 'users');
766+
ob[0].should.have.property('u', 2);
746767
done();
747768
});
748769
});

test/testUtils.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
var should = require('should');
2+
should.Assertion.add('haveSameItems', function(other) {
3+
this.params = { operator: 'to be have same items' };
4+
5+
this.obj.forEach(item => {
6+
//both arrays should at least contain the same items
7+
other.should.containEql(item);
8+
});
9+
// both arrays need to have the same number of items
10+
this.obj.length.should.be.equal(other.length);
11+
});
12+
113
if (typeof String.prototype.startsWith != 'function') {
214
String.prototype.startsWith = function(str) {
315
return this.slice(0, str.length) == str;

0 commit comments

Comments
 (0)