2016-05-04 00:10:46 +00:00
|
|
|
// Copyright IBM Corp. 2014,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
var path = require('path');
|
|
|
|
var loopback = require('../../');
|
|
|
|
var models = require('../fixtures/e2e/models');
|
|
|
|
var TestModel = models.TestModel;
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
describe('RemoteConnector', function() {
|
|
|
|
before(function() {
|
|
|
|
// setup the remote connector
|
|
|
|
var ds = loopback.createDataSource({
|
2015-01-16 06:51:53 +00:00
|
|
|
url: 'http://127.0.0.1:3000/api',
|
2014-04-14 19:25:41 +00:00
|
|
|
connector: loopback.Remote
|
|
|
|
});
|
|
|
|
TestModel.attachTo(ds);
|
|
|
|
});
|
|
|
|
|
2014-11-21 02:35:36 +00:00
|
|
|
it('should be able to call create', function(done) {
|
2014-04-14 19:25:41 +00:00
|
|
|
TestModel.create({
|
|
|
|
foo: 'bar'
|
|
|
|
}, function(err, inst) {
|
2014-11-21 02:35:36 +00:00
|
|
|
if (err) return done(err);
|
2016-05-06 20:50:01 +00:00
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
assert(inst.id);
|
2016-05-06 20:50:01 +00:00
|
|
|
|
2014-04-14 19:25:41 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-04-14 21:17:56 +00:00
|
|
|
|
2014-11-21 02:35:36 +00:00
|
|
|
it('should be able to call save', function(done) {
|
2014-04-14 21:17:56 +00:00
|
|
|
var m = new TestModel({
|
|
|
|
foo: 'bar'
|
|
|
|
});
|
|
|
|
m.save(function(err, data) {
|
2014-11-21 02:35:36 +00:00
|
|
|
if (err) return done(err);
|
2016-05-06 20:50:01 +00:00
|
|
|
|
2014-05-06 20:31:23 +00:00
|
|
|
assert(data.foo === 'bar');
|
2016-05-06 20:50:01 +00:00
|
|
|
|
2014-04-14 21:17:56 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-04-14 19:25:41 +00:00
|
|
|
});
|