-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
replication.e2e.js
37 lines (34 loc) · 1022 Bytes
/
replication.e2e.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var path = require('path');
var loopback = require('../../');
var models = require('../fixtures/e2e/models');
var TestModel = models.TestModel;
var LocalTestModel = TestModel.extend('LocalTestModel', {}, {
trackChanges: true
});
var assert = require('assert');
describe('Replication', function() {
before(function() {
// setup the remote connector
var ds = loopback.createDataSource({
url: 'http://localhost:3000/api',
connector: loopback.Remote
});
TestModel.attachTo(ds);
var memory = loopback.memory();
LocalTestModel.attachTo(memory);
});
it('should replicate local data to the remote', function (done) {
var RANDOM = Math.random();
LocalTestModel.create({
n: RANDOM
}, function(err, created) {
LocalTestModel.replicate(0, TestModel, function() {
if(err) return done(err);
TestModel.findOne({n: RANDOM}, function(err, found) {
assert.equal(created.id, found.id);
done();
});
});
});
});
});