Merge pull request #1318 from strongloop/fixup-for-cass
Fixup test support for Cassandra connector
This commit is contained in:
commit
14d966d159
|
@ -5008,11 +5008,12 @@ describe('relations', function() {
|
|||
});
|
||||
|
||||
it('should remove items from scope - and save parent', function(done) {
|
||||
debugger;
|
||||
Category.findById(category.id, function(err, cat) {
|
||||
if (err) return done(err);
|
||||
cat.items.at(0).destroy(function(err, link) {
|
||||
if (err) return done(err);
|
||||
cat.links.should.eql([]);
|
||||
cat.links.should.have.lengthOf(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -5022,7 +5023,7 @@ describe('relations', function() {
|
|||
Category.findById(category.id, function(err, cat) {
|
||||
if (err) return done(err);
|
||||
cat.name.should.equal('Category B');
|
||||
cat.links.should.eql([]);
|
||||
cat.links.should.have.lengthOf(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -5216,8 +5217,8 @@ describe('relations', function() {
|
|||
cat.jobIds.should.have.length(0);
|
||||
cat.jobs.create({name: 'Job 2'}, function(err, p) {
|
||||
if (err) return done(err);
|
||||
cat.jobIds.should.have.length(1);
|
||||
cat.jobIds.should.eql([p.id]);
|
||||
cat.jobIds.should.have.lengthOf(1);
|
||||
cat.jobIds[0].should.eql(p.id);
|
||||
p.name.should.equal('Job 2');
|
||||
job2 = p;
|
||||
done();
|
||||
|
@ -5239,7 +5240,8 @@ describe('relations', function() {
|
|||
|
||||
it('should find items on scope', function(done) {
|
||||
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) {
|
||||
if (err) return done(err);
|
||||
var p = jobs[0];
|
||||
|
@ -5252,7 +5254,8 @@ describe('relations', function() {
|
|||
|
||||
it('should find items on scope - findById', function(done) {
|
||||
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) {
|
||||
if (err) return done(err);
|
||||
p.should.be.instanceof(Job);
|
||||
|
@ -5397,10 +5400,8 @@ describe('relations', function() {
|
|||
Category.findOne(function(err, cat) {
|
||||
cat.jobs.reverse(function(err, ids) {
|
||||
var expected = [job3.id, job2.id];
|
||||
ids[0].should.eql(expected[0]);
|
||||
ids[1].should.eql(expected[1]);
|
||||
cat.jobIds[0].should.eql(expected[0]);
|
||||
cat.jobIds[1].should.eql(expected[1]);
|
||||
ids.should.eql(expected);
|
||||
cat.jobIds.should.eql(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -5437,8 +5438,8 @@ describe('relations', function() {
|
|||
Category.findOne(function(err, cat) {
|
||||
cat.jobs.destroy(job2.id, function(err) {
|
||||
if (err) return done(err);
|
||||
var expected = [job3.id];
|
||||
cat.jobIds.should.eql(expected);
|
||||
cat.jobIds.should.have.lengthOf(1);
|
||||
cat.jobIds[0].should.eql(job3.id);
|
||||
Job.exists(job2.id, function(err, exists) {
|
||||
if (err) return done(err);
|
||||
should.exist(exists);
|
||||
|
@ -5451,8 +5452,8 @@ describe('relations', function() {
|
|||
|
||||
it('should find items on scope - verify', function(done) {
|
||||
Category.findOne(function(err, cat) {
|
||||
var expected = [job3.id];
|
||||
cat.jobIds.should.eql(expected);
|
||||
cat.jobIds.should.have.lengthOf(1);
|
||||
cat.jobIds[0].should.eql(job3.id);
|
||||
cat.jobs(function(err, jobs) {
|
||||
if (err) return done(err);
|
||||
jobs.should.have.length(1);
|
||||
|
@ -5484,7 +5485,7 @@ describe('relations', function() {
|
|||
return cat.jobs.create({name: 'Job 2'})
|
||||
.then(function(p) {
|
||||
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');
|
||||
job2 = p;
|
||||
done();
|
||||
|
@ -5544,7 +5545,8 @@ describe('relations', function() {
|
|||
it('should find items on scope with promises - findById', function(done) {
|
||||
Category.findOne()
|
||||
.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);
|
||||
})
|
||||
.then(function(p) {
|
||||
|
@ -5599,7 +5601,9 @@ describe('relations', function() {
|
|||
.then(function(cat) {
|
||||
return cat.jobs.add(job1)
|
||||
.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.should.have.property('name');
|
||||
done();
|
||||
|
@ -5614,7 +5618,8 @@ describe('relations', function() {
|
|||
return cat.jobs.add(job3.id)
|
||||
.then(function(prod) {
|
||||
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.should.have.property('name');
|
||||
done();
|
||||
|
@ -5658,7 +5663,8 @@ describe('relations', function() {
|
|||
return cat.jobs.remove(job1.id)
|
||||
.then(function(ids) {
|
||||
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);
|
||||
done();
|
||||
});
|
||||
|
@ -5670,7 +5676,8 @@ describe('relations', function() {
|
|||
Category.findOne()
|
||||
.then(function(cat) {
|
||||
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();
|
||||
})
|
||||
.then(function(jobs) {
|
||||
|
@ -5699,21 +5706,6 @@ describe('relations', function() {
|
|||
});
|
||||
|
||||
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) {
|
||||
Category.findOne()
|
||||
.then(function(cat) {
|
||||
|
@ -5743,29 +5735,17 @@ describe('relations', function() {
|
|||
}).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) {
|
||||
Category.findOne()
|
||||
.then(function(cat) {
|
||||
return cat.jobs.destroy(job2.id)
|
||||
.then(function() {
|
||||
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);
|
||||
})
|
||||
.then(function(exists) {
|
||||
|
@ -5781,7 +5761,8 @@ describe('relations', function() {
|
|||
Category.findOne()
|
||||
.then(function(cat) {
|
||||
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();
|
||||
})
|
||||
.then(function(jobs) {
|
||||
|
|
Loading…
Reference in New Issue