loopback/test/e2e/remote-connector.e2e.js

38 lines
881 B
JavaScript
Raw Normal View History

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({
url: 'http://127.0.0.1:3000/api',
connector: loopback.Remote,
2014-04-14 19:25:41 +00:00
});
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',
2014-04-14 19:25:41 +00:00
}, function(err, inst) {
2014-11-21 02:35:36 +00:00
if (err) return done(err);
2014-04-14 19:25:41 +00:00
assert(inst.id);
done();
});
});
2014-11-21 02:35:36 +00:00
it('should be able to call save', function(done) {
var m = new TestModel({
foo: 'bar',
});
m.save(function(err, data) {
2014-11-21 02:35:36 +00:00
if (err) return done(err);
assert(data.foo === 'bar');
done();
});
});
2014-04-14 19:25:41 +00:00
});