From d1a08ef6b31652b4b6b867d445dc11a703f7cd97 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Sun, 7 Sep 2014 20:54:11 +0200 Subject: [PATCH] Add test case for Numeric ids (with optional forceId) --- test/relations.test.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/relations.test.js b/test/relations.test.js index 57987a76..86884434 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -2091,6 +2091,45 @@ describe('relations', function () { }); + describe('embedsMany - numeric ids + forceId', function () { + + before(function (done) { + tmp = getTransientDataSource(); + db = getSchema(); + Person = db.define('Person', {name: String}); + Address = tmp.define('Address', { + id: {type: Number, id:true}, + street: String + }); + + db.automigrate(function () { + Person.destroyAll(done); + }); + }); + + it('can be declared', function (done) { + Person.embedsMany(Address, {options: {forceId: true}}); + db.automigrate(done); + }); + + it('should create embedded items on scope', function(done) { + Person.create({ name: 'Fred' }, function(err, p) { + p.addressList.create({ street: 'Street 1' }, function(err, address) { + should.not.exist(err); + address.id.should.equal(1); + p.addressList.create({ street: 'Street 2' }, function(err, address) { + address.id.should.equal(2); + p.addressList.create({ id: 12345, street: 'Street 3' }, function(err, address) { + address.id.should.equal(3); + done(); + }); + }); + }); + }); + }); + + }); + describe('embedsMany - explicit ids', function () { before(function (done) { tmp = getTransientDataSource();