2013-04-09 16:02:36 +00:00
|
|
|
/**
|
2013-07-16 17:49:25 +00:00
|
|
|
* loopback test setup and support.
|
2013-04-09 16:02:36 +00:00
|
|
|
*/
|
2014-11-21 01:46:21 +00:00
|
|
|
|
2013-06-07 19:57:51 +00:00
|
|
|
assert = require('assert');
|
2013-12-12 03:31:16 +00:00
|
|
|
expect = require('chai').expect;
|
2013-07-16 17:49:25 +00:00
|
|
|
loopback = require('../');
|
|
|
|
memoryConnector = loopback.Memory;
|
|
|
|
GeoPoint = loopback.GeoPoint;
|
2013-06-11 18:07:49 +00:00
|
|
|
app = null;
|
2013-08-01 18:31:30 +00:00
|
|
|
TaskEmitter = require('strong-task-emitter');
|
2013-06-12 22:44:38 +00:00
|
|
|
request = require('supertest');
|
2014-05-03 03:04:06 +00:00
|
|
|
var RemoteObjects = require('strong-remoting');
|
2013-06-07 19:57:51 +00:00
|
|
|
|
2014-01-13 19:05:22 +00:00
|
|
|
// Speed up the password hashing algorithm
|
|
|
|
// for tests using the built-in User model
|
|
|
|
loopback.User.settings.saltWorkFactor = 4;
|
|
|
|
|
2014-11-21 02:35:36 +00:00
|
|
|
beforeEach(function() {
|
2014-02-04 19:27:14 +00:00
|
|
|
this.app = app = loopback();
|
2013-11-19 00:13:40 +00:00
|
|
|
|
|
|
|
// setup default data sources
|
|
|
|
loopback.setDefaultDataSourceForType('db', {
|
|
|
|
connector: loopback.Memory
|
|
|
|
});
|
|
|
|
|
|
|
|
loopback.setDefaultDataSourceForType('mail', {
|
|
|
|
connector: loopback.Mail,
|
|
|
|
transports: [
|
|
|
|
{type: 'STUB'}
|
|
|
|
]
|
|
|
|
});
|
2013-06-11 16:01:44 +00:00
|
|
|
});
|
|
|
|
|
2014-11-21 02:35:36 +00:00
|
|
|
assertValidDataSource = function(dataSource) {
|
2013-06-11 16:01:44 +00:00
|
|
|
// has methods
|
|
|
|
assert.isFunc(dataSource, 'createModel');
|
2013-06-21 23:48:53 +00:00
|
|
|
assert.isFunc(dataSource, 'discoverModelDefinitions');
|
|
|
|
assert.isFunc(dataSource, 'discoverSchema');
|
2013-07-12 19:40:36 +00:00
|
|
|
assert.isFunc(dataSource, 'enableRemote');
|
|
|
|
assert.isFunc(dataSource, 'disableRemote');
|
2013-06-11 16:01:44 +00:00
|
|
|
assert.isFunc(dataSource, 'defineOperation');
|
|
|
|
assert.isFunc(dataSource, 'operations');
|
2014-11-21 01:46:21 +00:00
|
|
|
};
|
2013-06-11 16:01:44 +00:00
|
|
|
|
2014-11-21 02:35:36 +00:00
|
|
|
assert.isFunc = function(obj, name) {
|
2013-06-11 16:01:44 +00:00
|
|
|
assert(obj, 'cannot assert function ' + name + ' on object that doesnt exist');
|
|
|
|
assert(typeof obj[name] === 'function', name + ' is not a function');
|
2014-11-21 01:46:21 +00:00
|
|
|
};
|