parent
6342a0387f
commit
5d10c72664
|
@ -856,8 +856,8 @@ describe('basic-querying', function() {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
users.length.should.be.equal(2);
|
users.length.should.be.equal(2);
|
||||||
var expectedUsers = ['John Lennon', 'Paul McCartney'];
|
var expectedUsers = ['John Lennon', 'Paul McCartney'];
|
||||||
(expectedUsers.indexOf(users[0].name) > -1).should.be.ok();
|
expectedUsers.indexOf(users[0].name).should.not.equal(-1);
|
||||||
(expectedUsers.indexOf(users[1].name) > -1).should.be.ok();
|
expectedUsers.indexOf(users[1].name).should.not.equal(-1);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -574,7 +574,7 @@ describe('relations', function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
db = getSchema();
|
db = getSchema();
|
||||||
Physician = db.define('Physician', {name: String});
|
Physician = db.define('Physician', {name: String});
|
||||||
Patient = db.define('Patient', {name: String, age: Number});
|
Patient = db.define('Patient', {name: String, age: Number, sequence: Number});
|
||||||
Appointment = db.define('Appointment', {date: {type: Date,
|
Appointment = db.define('Appointment', {date: {type: Date,
|
||||||
default: function() {
|
default: function() {
|
||||||
return new Date();
|
return new Date();
|
||||||
|
@ -734,7 +734,7 @@ describe('relations', function() {
|
||||||
context('with filter skip', function() {
|
context('with filter skip', function() {
|
||||||
bdd.itIf(connectorCapabilities.supportPagination !== false,
|
bdd.itIf(connectorCapabilities.supportPagination !== false,
|
||||||
'skips the first patient', function(done) {
|
'skips the first patient', function(done) {
|
||||||
physician.patients({skip: 1}, function(err, ch) {
|
physician.patients({skip: 1, order: 'sequence'}, function(err, ch) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
should.exist(ch);
|
should.exist(ch);
|
||||||
ch.should.have.lengthOf(2);
|
ch.should.have.lengthOf(2);
|
||||||
|
@ -767,7 +767,7 @@ describe('relations', function() {
|
||||||
});
|
});
|
||||||
context('with filter limit', function() {
|
context('with filter limit', function() {
|
||||||
it('limits to 1 result', function(done) {
|
it('limits to 1 result', function(done) {
|
||||||
physician.patients({limit: 1}, function(err, ch) {
|
physician.patients({limit: 1, order: 'sequence'}, function(err, ch) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
should.exist(ch);
|
should.exist(ch);
|
||||||
ch.should.have.lengthOf(1);
|
ch.should.have.lengthOf(1);
|
||||||
|
@ -782,7 +782,10 @@ describe('relations', function() {
|
||||||
});
|
});
|
||||||
context('with filter fields', function() {
|
context('with filter fields', function() {
|
||||||
it('includes field \'name\' but not \'age\'', function(done) {
|
it('includes field \'name\' but not \'age\'', function(done) {
|
||||||
var fieldsFilter = {fields: {name: true, age: false}};
|
var fieldsFilter = {
|
||||||
|
fields: {name: true, age: false},
|
||||||
|
order: 'sequence',
|
||||||
|
};
|
||||||
physician.patients(fieldsFilter, function(err, ch) {
|
physician.patients(fieldsFilter, function(err, ch) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
should.exist(ch);
|
should.exist(ch);
|
||||||
|
@ -832,8 +835,16 @@ describe('relations', function() {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
should.exist(ch);
|
should.exist(ch);
|
||||||
ch.should.have.lengthOf(2);
|
ch.should.have.lengthOf(2);
|
||||||
var resultIdArr = [ch[0].id, ch[1].id];
|
if (typeof idArr[0] === 'object') {
|
||||||
assert.deepEqual(resultIdArr, idArr);
|
// mongodb returns `id` as an object
|
||||||
|
idArr[0] = idArr[0].toString();
|
||||||
|
idArr[1] = idArr[1].toString();
|
||||||
|
idArr.indexOf(ch[0].id.toString()).should.not.equal(-1);
|
||||||
|
idArr.indexOf(ch[1].id.toString()).should.not.equal(-1);
|
||||||
|
} else {
|
||||||
|
idArr.indexOf(ch[0].id).should.not.equal(-1);
|
||||||
|
idArr.indexOf(ch[1].id).should.not.equal(-1);
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -888,10 +899,12 @@ describe('relations', function() {
|
||||||
|
|
||||||
function createSampleData(done) {
|
function createSampleData(done) {
|
||||||
Physician.create(function(err, result) {
|
Physician.create(function(err, result) {
|
||||||
result.patients.create({name: 'a', age: '10'}, function(err, p) {
|
result.patients.create({name: 'a', age: '10', sequence: 1},
|
||||||
|
function(err, p) {
|
||||||
samplePatientId = p.id;
|
samplePatientId = p.id;
|
||||||
result.patients.create({name: 'z', age: '20'}, function() {
|
result.patients.create({name: 'z', age: '20', sequence: 2},
|
||||||
result.patients.create({name: 'c'}, function() {
|
function() {
|
||||||
|
result.patients.create({name: 'c', sequence: 3}, function() {
|
||||||
physician = result;
|
physician = result;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue