Add a test for autoAttach
This commit is contained in:
parent
5586c54c49
commit
f08b9427ab
|
@ -15,6 +15,32 @@ describe('loopback', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('loopback.autoAttach', function () {
|
||||||
|
it('doesn\'t overwrite model with datasource configured', function () {
|
||||||
|
var ds1 = loopback.createDataSource('db1', {
|
||||||
|
connector: loopback.Memory
|
||||||
|
});
|
||||||
|
|
||||||
|
// setup default data sources
|
||||||
|
loopback.setDefaultDataSourceForType('db', ds1);
|
||||||
|
|
||||||
|
var ds2 = loopback.createDataSource('db2', {
|
||||||
|
connector: loopback.Memory
|
||||||
|
});
|
||||||
|
|
||||||
|
var model1 = ds2.createModel('m1', {});
|
||||||
|
|
||||||
|
var model2 = loopback.createModel('m2');
|
||||||
|
model2.autoAttach = 'db';
|
||||||
|
|
||||||
|
// auto attach data sources to models
|
||||||
|
loopback.autoAttach();
|
||||||
|
|
||||||
|
assert(model1.dataSource === ds2);
|
||||||
|
assert(model2.dataSource === ds1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('loopback.remoteMethod(Model, fn, [options]);', function() {
|
describe('loopback.remoteMethod(Model, fn, [options]);', function() {
|
||||||
it("Setup a remote method.", function() {
|
it("Setup a remote method.", function() {
|
||||||
var Product = loopback.createModel('product', {price: Number});
|
var Product = loopback.createModel('product', {price: Number});
|
||||||
|
|
Loading…
Reference in New Issue