Fixup test support for Cassandra connector
This commit is contained in:
parent
bff4ea7fd5
commit
0f9100f185
|
@ -5008,11 +5008,12 @@ describe('relations', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove items from scope - and save parent', function(done) {
|
it('should remove items from scope - and save parent', function(done) {
|
||||||
|
debugger;
|
||||||
Category.findById(category.id, function(err, cat) {
|
Category.findById(category.id, function(err, cat) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
cat.items.at(0).destroy(function(err, link) {
|
cat.items.at(0).destroy(function(err, link) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
cat.links.should.eql([]);
|
cat.links.should.have.lengthOf(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -5022,7 +5023,7 @@ describe('relations', function() {
|
||||||
Category.findById(category.id, function(err, cat) {
|
Category.findById(category.id, function(err, cat) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
cat.name.should.equal('Category B');
|
cat.name.should.equal('Category B');
|
||||||
cat.links.should.eql([]);
|
cat.links.should.have.lengthOf(0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -5216,8 +5217,8 @@ describe('relations', function() {
|
||||||
cat.jobIds.should.have.length(0);
|
cat.jobIds.should.have.length(0);
|
||||||
cat.jobs.create({name: 'Job 2'}, function(err, p) {
|
cat.jobs.create({name: 'Job 2'}, function(err, p) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
cat.jobIds.should.have.length(1);
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
cat.jobIds.should.eql([p.id]);
|
cat.jobIds[0].should.eql(p.id);
|
||||||
p.name.should.equal('Job 2');
|
p.name.should.equal('Job 2');
|
||||||
job2 = p;
|
job2 = p;
|
||||||
done();
|
done();
|
||||||
|
@ -5239,7 +5240,8 @@ describe('relations', function() {
|
||||||
|
|
||||||
it('should find items on scope', function(done) {
|
it('should find items on scope', function(done) {
|
||||||
Category.findOne(function(err, cat) {
|
Category.findOne(function(err, cat) {
|
||||||
cat.jobIds.should.eql([job2.id]);
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
|
cat.jobIds[0].should.eql(job2.id);
|
||||||
cat.jobs(function(err, jobs) {
|
cat.jobs(function(err, jobs) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
var p = jobs[0];
|
var p = jobs[0];
|
||||||
|
@ -5252,7 +5254,8 @@ describe('relations', function() {
|
||||||
|
|
||||||
it('should find items on scope - findById', function(done) {
|
it('should find items on scope - findById', function(done) {
|
||||||
Category.findOne(function(err, cat) {
|
Category.findOne(function(err, cat) {
|
||||||
cat.jobIds.should.eql([job2.id]);
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
|
cat.jobIds[0].should.eql(job2.id);
|
||||||
cat.jobs.findById(job2.id, function(err, p) {
|
cat.jobs.findById(job2.id, function(err, p) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
p.should.be.instanceof(Job);
|
p.should.be.instanceof(Job);
|
||||||
|
@ -5397,10 +5400,8 @@ describe('relations', function() {
|
||||||
Category.findOne(function(err, cat) {
|
Category.findOne(function(err, cat) {
|
||||||
cat.jobs.reverse(function(err, ids) {
|
cat.jobs.reverse(function(err, ids) {
|
||||||
var expected = [job3.id, job2.id];
|
var expected = [job3.id, job2.id];
|
||||||
ids[0].should.eql(expected[0]);
|
ids.should.eql(expected);
|
||||||
ids[1].should.eql(expected[1]);
|
cat.jobIds.should.eql(expected);
|
||||||
cat.jobIds[0].should.eql(expected[0]);
|
|
||||||
cat.jobIds[1].should.eql(expected[1]);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -5437,8 +5438,8 @@ describe('relations', function() {
|
||||||
Category.findOne(function(err, cat) {
|
Category.findOne(function(err, cat) {
|
||||||
cat.jobs.destroy(job2.id, function(err) {
|
cat.jobs.destroy(job2.id, function(err) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
var expected = [job3.id];
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds[0].should.eql(job3.id);
|
||||||
Job.exists(job2.id, function(err, exists) {
|
Job.exists(job2.id, function(err, exists) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
should.exist(exists);
|
should.exist(exists);
|
||||||
|
@ -5451,8 +5452,8 @@ describe('relations', function() {
|
||||||
|
|
||||||
it('should find items on scope - verify', function(done) {
|
it('should find items on scope - verify', function(done) {
|
||||||
Category.findOne(function(err, cat) {
|
Category.findOne(function(err, cat) {
|
||||||
var expected = [job3.id];
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds[0].should.eql(job3.id);
|
||||||
cat.jobs(function(err, jobs) {
|
cat.jobs(function(err, jobs) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
jobs.should.have.length(1);
|
jobs.should.have.length(1);
|
||||||
|
@ -5484,7 +5485,7 @@ describe('relations', function() {
|
||||||
return cat.jobs.create({name: 'Job 2'})
|
return cat.jobs.create({name: 'Job 2'})
|
||||||
.then(function(p) {
|
.then(function(p) {
|
||||||
cat.jobIds.should.have.length(1);
|
cat.jobIds.should.have.length(1);
|
||||||
cat.jobIds.should.eql([p.id]);
|
cat.jobIds[0].should.eql(p.id);
|
||||||
p.name.should.equal('Job 2');
|
p.name.should.equal('Job 2');
|
||||||
job2 = p;
|
job2 = p;
|
||||||
done();
|
done();
|
||||||
|
@ -5544,7 +5545,8 @@ describe('relations', function() {
|
||||||
it('should find items on scope with promises - findById', function(done) {
|
it('should find items on scope with promises - findById', function(done) {
|
||||||
Category.findOne()
|
Category.findOne()
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
cat.jobIds.should.eql([job2.id]);
|
cat.jobIds.should.have.lengthOf(1);
|
||||||
|
cat.jobIds[0].should.eql(job2.id);
|
||||||
return cat.jobs.findById(job2.id);
|
return cat.jobs.findById(job2.id);
|
||||||
})
|
})
|
||||||
.then(function(p) {
|
.then(function(p) {
|
||||||
|
@ -5599,7 +5601,9 @@ describe('relations', function() {
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
return cat.jobs.add(job1)
|
return cat.jobs.add(job1)
|
||||||
.then(function(prod) {
|
.then(function(prod) {
|
||||||
cat.jobIds.should.eql([job2.id, job1.id]);
|
var expected = [job2.id, job1.id];
|
||||||
|
cat.jobIds.should.have.lengthOf(expected.length);
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
prod.id.should.eql(job1.id);
|
prod.id.should.eql(job1.id);
|
||||||
prod.should.have.property('name');
|
prod.should.have.property('name');
|
||||||
done();
|
done();
|
||||||
|
@ -5614,7 +5618,8 @@ describe('relations', function() {
|
||||||
return cat.jobs.add(job3.id)
|
return cat.jobs.add(job3.id)
|
||||||
.then(function(prod) {
|
.then(function(prod) {
|
||||||
var expected = [job2.id, job1.id, job3.id];
|
var expected = [job2.id, job1.id, job3.id];
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds.should.have.lengthOf(expected.length);
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
prod.id.should.eql(job3.id);
|
prod.id.should.eql(job3.id);
|
||||||
prod.should.have.property('name');
|
prod.should.have.property('name');
|
||||||
done();
|
done();
|
||||||
|
@ -5658,7 +5663,8 @@ describe('relations', function() {
|
||||||
return cat.jobs.remove(job1.id)
|
return cat.jobs.remove(job1.id)
|
||||||
.then(function(ids) {
|
.then(function(ids) {
|
||||||
var expected = [job2.id, job3.id];
|
var expected = [job2.id, job3.id];
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds.should.have.lengthOf(expected.length);
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
cat.jobIds.should.eql(ids);
|
cat.jobIds.should.eql(ids);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -5670,7 +5676,8 @@ describe('relations', function() {
|
||||||
Category.findOne()
|
Category.findOne()
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
var expected = [job2.id, job3.id];
|
var expected = [job2.id, job3.id];
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds.should.have.lengthOf(expected.length);
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
return cat.jobs.getAsync();
|
return cat.jobs.getAsync();
|
||||||
})
|
})
|
||||||
.then(function(jobs) {
|
.then(function(jobs) {
|
||||||
|
@ -5699,21 +5706,6 @@ describe('relations', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
bdd.itIf(connectorCapabilities.adhocSort !== false,
|
bdd.itIf(connectorCapabilities.adhocSort !== false,
|
||||||
'should allow custom scope methods with promises - reverse', function(done) {
|
|
||||||
Category.findOne()
|
|
||||||
.then(function(cat) {
|
|
||||||
return cat.jobs.reverse()
|
|
||||||
.then(function(ids) {
|
|
||||||
var expected = [job3.id, job2.id];
|
|
||||||
cat.jobIds.should.eql(expected);
|
|
||||||
cat.jobIds.should.eql(ids);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
bdd.itIf(connectorCapabilities.adhocSort === false,
|
|
||||||
'should allow custom scope methods with promises - reverse', function(done) {
|
'should allow custom scope methods with promises - reverse', function(done) {
|
||||||
Category.findOne()
|
Category.findOne()
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
|
@ -5743,29 +5735,17 @@ describe('relations', function() {
|
||||||
}).catch(done);
|
}).catch(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
bdd.itIf(connectorCapabilities.adhocSort === false &&
|
|
||||||
connectorCapabilities.supportInclude !== false,
|
|
||||||
'should include related items from scope with promises', function(done) {
|
|
||||||
Category.find({include: 'jobs'})
|
|
||||||
.then(function(categories) {
|
|
||||||
categories.should.have.length(1);
|
|
||||||
var cat = categories[0].toObject();
|
|
||||||
cat.name.should.equal('Category A');
|
|
||||||
cat.jobIds.should.have.length(2);
|
|
||||||
var theExpectedIds = [job1.id, job2.id, job3.id];
|
|
||||||
cat.jobIds[0].id.should.be.oneOf(theExpectedIds);
|
|
||||||
cat.jobIds[1].id.should.be.oneOf(theExpectedIds);
|
|
||||||
done();
|
|
||||||
}).catch(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should destroy items from scope with promises - destroyById', function(done) {
|
it('should destroy items from scope with promises - destroyById', function(done) {
|
||||||
Category.findOne()
|
Category.findOne()
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
return cat.jobs.destroy(job2.id)
|
return cat.jobs.destroy(job2.id)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
var expected = [job3.id];
|
var expected = [job3.id];
|
||||||
cat.jobIds[0].should.eql(expected[0]);
|
if (connectorCapabilities.adhocSort !== false) {
|
||||||
|
cat.jobIds.should.eql(expected);
|
||||||
|
} else {
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
|
}
|
||||||
return Job.exists(job2.id);
|
return Job.exists(job2.id);
|
||||||
})
|
})
|
||||||
.then(function(exists) {
|
.then(function(exists) {
|
||||||
|
@ -5781,7 +5761,8 @@ describe('relations', function() {
|
||||||
Category.findOne()
|
Category.findOne()
|
||||||
.then(function(cat) {
|
.then(function(cat) {
|
||||||
var expected = [job3.id];
|
var expected = [job3.id];
|
||||||
cat.jobIds.should.eql(expected);
|
cat.jobIds.should.have.lengthOf(expected.length);
|
||||||
|
cat.jobIds.should.containDeep(expected);
|
||||||
return cat.jobs.getAsync();
|
return cat.jobs.getAsync();
|
||||||
})
|
})
|
||||||
.then(function(jobs) {
|
.then(function(jobs) {
|
||||||
|
|
Loading…
Reference in New Issue