2016-11-08 16:59:30 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright 2016 Realm Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/* eslint-env es6, node */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const Realm = require('realm');
|
|
|
|
const TestCase = require('./asserts');
|
2017-07-07 13:38:13 +00:00
|
|
|
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
2016-11-08 16:59:30 +00:00
|
|
|
|
|
|
|
function uuid() {
|
2016-11-10 18:45:43 +00:00
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
|
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
|
|
return v.toString(16);
|
|
|
|
});
|
2016-11-08 16:59:30 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 18:34:39 +00:00
|
|
|
function assertIsUser(user, isAdmin) {
|
2016-11-10 18:45:43 +00:00
|
|
|
TestCase.assertType(user, 'object');
|
|
|
|
TestCase.assertType(user.token, 'string');
|
|
|
|
TestCase.assertType(user.identity, 'string');
|
|
|
|
TestCase.assertInstanceOf(user, Realm.Sync.User);
|
|
|
|
if (isAdmin !== undefined) {
|
|
|
|
TestCase.assertEqual(user.isAdmin, isAdmin);
|
|
|
|
}
|
2016-11-10 18:34:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 20:53:36 +00:00
|
|
|
function assertIsSameUser(value, user) {
|
|
|
|
assertIsUser(value);
|
|
|
|
TestCase.assertEqual(value.token, user.token);
|
|
|
|
TestCase.assertEqual(value.identity, user.identity);
|
|
|
|
TestCase.assertEqual(value.isAdmin, user.isAdmin);
|
|
|
|
}
|
|
|
|
|
2017-01-31 13:07:29 +00:00
|
|
|
function assertIsError(error, message) {
|
2016-11-10 18:45:43 +00:00
|
|
|
TestCase.assertInstanceOf(error, Error, 'The API should return an Error');
|
2017-01-31 13:07:29 +00:00
|
|
|
if (message) {
|
|
|
|
TestCase.assertEqual(error.message, message);
|
2016-11-10 18:45:43 +00:00
|
|
|
}
|
2016-11-10 18:34:39 +00:00
|
|
|
}
|
|
|
|
|
2017-09-18 06:44:11 +00:00
|
|
|
function assertIsAuthError(error, code, title) {
|
2016-11-10 18:45:43 +00:00
|
|
|
TestCase.assertInstanceOf(error, Realm.Sync.AuthError, 'The API should return an AuthError');
|
|
|
|
if (code) {
|
|
|
|
TestCase.assertEqual(error.code, code);
|
|
|
|
}
|
2017-09-18 06:44:11 +00:00
|
|
|
if (title) {
|
|
|
|
TestCase.assertEqual(error.title, title);
|
2016-11-10 18:45:43 +00:00
|
|
|
}
|
2016-11-10 18:34:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 02:06:06 +00:00
|
|
|
function failOnError(error) {
|
|
|
|
if (error) {
|
2017-08-31 22:28:37 +00:00
|
|
|
throw new Error(`Unexpected error in test: ${error}\n${error.stack}`);
|
2016-11-11 02:06:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test the given requestFunc, passing it the given callback after it's been wrapped appropriately.
|
|
|
|
// This function makes sure that errors thrown in the async callback rejects the promise (making tests actually run).
|
|
|
|
function callbackTest(requestFunc, callback) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
function callbackWrapper() {
|
|
|
|
try {
|
|
|
|
callback.apply(this, Array.from(arguments));
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
requestFunc(callbackWrapper);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-08 16:59:30 +00:00
|
|
|
module.exports = {
|
2017-08-31 22:28:37 +00:00
|
|
|
|
2016-11-11 02:06:06 +00:00
|
|
|
testLogout() {
|
|
|
|
var username = uuid();
|
|
|
|
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => {
|
|
|
|
failOnError(error);
|
|
|
|
assertIsUser(user);
|
|
|
|
|
|
|
|
assertIsSameUser(user, Realm.Sync.User.current);
|
|
|
|
user.logout();
|
|
|
|
|
|
|
|
// Is now logged out.
|
|
|
|
TestCase.assertUndefined(Realm.Sync.User.current);
|
|
|
|
|
|
|
|
// Can we open a realm with the registered user?
|
2016-11-11 08:14:52 +00:00
|
|
|
TestCase.assertThrows(function() {
|
2016-11-14 18:48:50 +00:00
|
|
|
var _realm = new Realm({sync: {user: user, url: 'realm://localhost:9080/~/test'}});
|
2016-11-11 08:14:52 +00:00
|
|
|
});
|
2016-11-11 02:06:06 +00:00
|
|
|
})
|
|
|
|
},
|
2016-11-10 20:53:36 +00:00
|
|
|
|
2016-11-10 18:45:43 +00:00
|
|
|
testRegisterUser() {
|
|
|
|
var username = uuid();
|
2016-11-11 02:06:06 +00:00
|
|
|
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => {
|
|
|
|
failOnError(error);
|
|
|
|
assertIsUser(user);
|
2016-11-10 18:45:43 +00:00
|
|
|
|
2016-11-11 02:06:06 +00:00
|
|
|
// Can we open a realm with the registered user?
|
|
|
|
var realm = new Realm({sync: {user: user, url: 'realm://localhost:9080/~/test'}});
|
|
|
|
TestCase.assertInstanceOf(realm, Realm);
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testRegisterExistingUser() {
|
|
|
|
var username = uuid();
|
2017-09-18 11:09:04 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2016-11-11 02:06:06 +00:00
|
|
|
Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => {
|
2017-09-18 11:09:04 +00:00
|
|
|
failOnError(error);
|
|
|
|
assertIsUser(user);
|
|
|
|
|
|
|
|
Realm.Sync.User.register('http://localhost:9080', username, 'password', (error, user) => {
|
2017-10-16 21:51:47 +00:00
|
|
|
try {
|
2017-09-22 17:22:17 +00:00
|
|
|
assertIsAuthError(error, 611, "The provided credentials are invalid or the user does not exist.");
|
2017-09-18 11:09:04 +00:00
|
|
|
TestCase.assertUndefined(user);
|
|
|
|
resolve();
|
2017-10-16 21:51:47 +00:00
|
|
|
} catch(e) {
|
2017-09-18 11:09:04 +00:00
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
});
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
});
|
2017-08-31 22:28:37 +00:00
|
|
|
},
|
2016-11-10 18:45:43 +00:00
|
|
|
|
|
|
|
testRegisterMissingUsername() {
|
2017-03-20 11:52:41 +00:00
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
|
TestCase.assertThrows(() => {
|
|
|
|
Realm.Sync.User.register('http://localhost:9080', undefined, 'password', () => {});
|
|
|
|
});
|
|
|
|
resolve();
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testRegisterMissingPassword() {
|
|
|
|
var username = uuid();
|
2017-03-20 11:52:41 +00:00
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
|
TestCase.assertThrows(() => {
|
|
|
|
Realm.Sync.User.register('http://localhost:9080', username, undefined, () => {});
|
|
|
|
});
|
|
|
|
resolve();
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testRegisterServerOffline() {
|
|
|
|
var username = uuid();
|
2016-11-11 02:06:06 +00:00
|
|
|
// Because it waits for answer this takes some time..
|
|
|
|
return callbackTest((callback) => Realm.Sync.User.register('http://fake_host.local', username, 'password', callback), (error, user) => {
|
2017-01-31 13:07:29 +00:00
|
|
|
assertIsError(error);
|
2016-11-11 02:06:06 +00:00
|
|
|
TestCase.assertUndefined(user);
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testLogin() {
|
2017-01-31 13:07:29 +00:00
|
|
|
var username = uuid();
|
|
|
|
// Create user, logout the new user, then login
|
2017-04-06 08:00:29 +00:00
|
|
|
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', username, 'password', callback), (error, user) => {
|
2016-11-11 02:06:06 +00:00
|
|
|
failOnError(error);
|
2017-01-31 13:07:29 +00:00
|
|
|
user.logout();
|
2016-11-11 02:06:06 +00:00
|
|
|
|
2017-01-31 13:07:29 +00:00
|
|
|
Realm.Sync.User.login('http://localhost:9080', username, 'password', (error, user) => {
|
|
|
|
failOnError(error);
|
|
|
|
assertIsUser(user);
|
|
|
|
|
|
|
|
// Can we open a realm with the logged-in user?
|
|
|
|
var realm = new Realm({ sync: { user: user, url: 'realm://localhost:9080/~/test' } });
|
|
|
|
TestCase.assertInstanceOf(realm, Realm);
|
|
|
|
realm.close();
|
|
|
|
});
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testLoginMissingUsername() {
|
2017-03-20 11:52:41 +00:00
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
|
TestCase.assertThrows(() => {
|
|
|
|
Realm.Sync.User.login('http://localhost:9080', undefined, 'password', () => {});
|
|
|
|
});
|
|
|
|
resolve();
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testLoginMissingPassword() {
|
|
|
|
var username = uuid();
|
2017-03-20 11:52:41 +00:00
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
|
TestCase.assertThrows(() => {
|
|
|
|
Realm.Sync.User.login('http://localhost:9080', username, undefined, () => {});
|
|
|
|
});
|
|
|
|
resolve();
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testLoginNonExistingUser() {
|
2016-11-11 02:06:06 +00:00
|
|
|
return callbackTest((callback) => Realm.Sync.User.login('http://localhost:9080', 'does_not', 'exist', callback), (error, user) => {
|
2017-09-22 17:22:17 +00:00
|
|
|
assertIsAuthError(error, 611, "The provided credentials are invalid or the user does not exist.");
|
2016-11-11 02:06:06 +00:00
|
|
|
TestCase.assertUndefined(user);
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testLoginServerOffline() {
|
|
|
|
var username = uuid();
|
2017-01-31 13:07:29 +00:00
|
|
|
|
|
|
|
// Because it waits for answer this takes some time..
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
Realm.Sync.User.register('http://fake_host.local', username, 'password', (error, user) => {
|
|
|
|
try {
|
|
|
|
assertIsError(error);
|
|
|
|
TestCase.assertUndefined(user);
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
catch (e) { reject(e) }
|
|
|
|
});
|
2016-11-10 18:45:43 +00:00
|
|
|
});
|
|
|
|
},
|
2016-11-10 18:34:39 +00:00
|
|
|
|
2016-11-10 20:53:36 +00:00
|
|
|
testAll() {
|
2017-04-06 11:25:40 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2016-11-10 20:53:36 +00:00
|
|
|
let all;
|
|
|
|
all = Realm.Sync.User.all;
|
2016-11-10 21:55:22 +00:00
|
|
|
TestCase.assertArrayLength(Object.keys(all), 0);
|
2016-11-10 20:53:36 +00:00
|
|
|
|
2017-04-06 11:25:40 +00:00
|
|
|
callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', callback), (error, user1) => {
|
2016-11-11 02:21:57 +00:00
|
|
|
failOnError(error);
|
2016-11-11 02:06:06 +00:00
|
|
|
|
2016-11-10 20:53:36 +00:00
|
|
|
all = Realm.Sync.User.all;
|
2016-11-10 21:55:22 +00:00
|
|
|
TestCase.assertArrayLength(Object.keys(all), 1);
|
|
|
|
assertIsSameUser(all[user1.identity], user1);
|
2016-11-10 20:53:36 +00:00
|
|
|
|
|
|
|
Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', (error, user2) => {
|
2016-11-11 02:21:57 +00:00
|
|
|
failOnError(error);
|
2016-11-11 02:06:06 +00:00
|
|
|
|
2016-11-10 20:53:36 +00:00
|
|
|
all = Realm.Sync.User.all;
|
2016-11-10 21:55:22 +00:00
|
|
|
TestCase.assertArrayLength(Object.keys(all), 2);
|
2016-11-10 20:53:36 +00:00
|
|
|
// NOTE: the list of users is in latest-first order.
|
2016-11-10 21:55:22 +00:00
|
|
|
assertIsSameUser(all[user2.identity], user2);
|
|
|
|
assertIsSameUser(all[user1.identity], user1);
|
2016-11-11 02:06:06 +00:00
|
|
|
|
|
|
|
user2.logout();
|
|
|
|
all = Realm.Sync.User.all;
|
|
|
|
TestCase.assertArrayLength(Object.keys(all), 1);
|
|
|
|
assertIsSameUser(all[user1.identity], user1);
|
|
|
|
|
|
|
|
user1.logout();
|
|
|
|
all = Realm.Sync.User.all;
|
|
|
|
TestCase.assertArrayLength(Object.keys(all), 0);
|
2016-11-10 20:53:36 +00:00
|
|
|
resolve();
|
|
|
|
});
|
2017-04-06 11:25:40 +00:00
|
|
|
}).catch(e => reject(e));
|
|
|
|
});
|
2016-11-10 20:53:36 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
testCurrent() {
|
2017-04-06 11:25:40 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
TestCase.assertUndefined(Realm.Sync.User.current);
|
2016-11-10 20:53:36 +00:00
|
|
|
|
2017-04-06 11:25:40 +00:00
|
|
|
callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', callback), (error, user1) => {
|
2016-11-11 02:21:57 +00:00
|
|
|
failOnError(error);
|
2016-11-11 02:06:06 +00:00
|
|
|
assertIsSameUser(Realm.Sync.User.current, user1);
|
|
|
|
|
2017-04-06 11:25:40 +00:00
|
|
|
Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', (error, user2) => {
|
|
|
|
failOnError(error);
|
|
|
|
TestCase.assertThrows(() => Realm.Sync.User.current, 'We expect Realm.Sync.User.current to throw if > 1 user.');
|
|
|
|
user2.logout();
|
2016-11-11 02:06:06 +00:00
|
|
|
|
2017-04-06 11:25:40 +00:00
|
|
|
assertIsSameUser(Realm.Sync.User.current, user1);
|
|
|
|
|
|
|
|
user1.logout();
|
|
|
|
TestCase.assertUndefined(Realm.Sync.User.current);
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
|
|
});
|
2017-04-06 15:26:36 +00:00
|
|
|
}).catch(e => reject(e));
|
|
|
|
});
|
2017-01-31 21:56:09 +00:00
|
|
|
},
|
2016-11-10 20:53:36 +00:00
|
|
|
|
2017-01-31 21:56:09 +00:00
|
|
|
testManagementRealm() {
|
|
|
|
return callbackTest((callback) => Realm.Sync.User.register('http://localhost:9080', uuid(), 'password', callback), (error, user) => {
|
|
|
|
failOnError(error);
|
|
|
|
|
|
|
|
let realm = user.openManagementRealm();
|
|
|
|
TestCase.assertInstanceOf(realm, Realm);
|
|
|
|
|
|
|
|
let objectSchemaNames = realm.schema.map(o => o.name);
|
|
|
|
TestCase.assertArraysEqual(objectSchemaNames, [ 'PermissionChange', 'PermissionOffer', 'PermissionOfferResponse' ]);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-09-20 23:38:22 +00:00
|
|
|
testRetrieveAccount() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (!isNodeProcess) {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.testAdminUserInfo) {
|
|
|
|
reject("Test requires an admin user");
|
|
|
|
}
|
|
|
|
|
|
|
|
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
|
|
|
if (error) {
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
|
|
|
|
|
|
|
user.retrieveAccount('password', global.testAdminUserInfo.username)
|
|
|
|
.then(account => {
|
2017-09-22 17:22:17 +00:00
|
|
|
TestCase.assertEqual(account.accounts[0].provider_id, global.testAdminUserInfo.username);
|
|
|
|
TestCase.assertEqual(account.accounts[0].provider, 'password');
|
|
|
|
TestCase.assertTrue(account.is_admin);
|
|
|
|
TestCase.assertTrue(account.user_id);
|
2017-09-20 23:38:22 +00:00
|
|
|
resolve();
|
|
|
|
})
|
|
|
|
.catch(e => reject(e));
|
|
|
|
})
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
testRetrieveNotExistingAccount() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (!isNodeProcess) {
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.testAdminUserInfo) {
|
|
|
|
reject("Test requires an admin user");
|
|
|
|
}
|
|
|
|
|
|
|
|
Realm.Sync.User.login('http://localhost:9080', global.testAdminUserInfo.username, global.testAdminUserInfo.password, (error, user) => {
|
|
|
|
if (error) {
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestCase.assertTrue(user.isAdmin, "Test requires an admin user");
|
|
|
|
|
|
|
|
let notExistingUsername = uuid();
|
|
|
|
user.retrieveAccount('password', notExistingUsername)
|
|
|
|
.then(account => {
|
|
|
|
reject("Retrieving not existing account should fail");
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
try {
|
2017-09-22 17:22:17 +00:00
|
|
|
TestCase.assertEqual(e.status, 404);
|
|
|
|
TestCase.assertEqual(e.code, 612);
|
|
|
|
TestCase.assertEqual(e.message, "The account does not exist.");
|
|
|
|
TestCase.assertEqual(e.type, "https://realm.io/docs/object-server/problems/unknown-account");
|
2017-09-20 23:38:22 +00:00
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
resolve()
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
},
|
2017-07-06 09:27:01 +00:00
|
|
|
|
2017-01-31 21:56:09 +00:00
|
|
|
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
2016-11-11 17:16:40 +00:00
|
|
|
testSynchronizeChangesWithTwoClientsAndOneUser() {
|
|
|
|
// Test Schema
|
|
|
|
class Foo {}
|
|
|
|
Foo.schema = {
|
|
|
|
name: 'Foo',
|
|
|
|
properties: {
|
|
|
|
string: 'string',
|
|
|
|
bars: { type: 'list', objectType: 'Bar' },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
class Bar {}
|
|
|
|
Bar.schema = {
|
|
|
|
name: 'Bar',
|
|
|
|
properties: { integer: 'int' },
|
|
|
|
};
|
|
|
|
|
|
|
|
const schema = [Foo.schema, Bar.schema];
|
2016-11-29 09:51:26 +00:00
|
|
|
|
2016-11-11 17:16:40 +00:00
|
|
|
// Create a user, open two clients at different local paths, synchronize changes
|
|
|
|
const username = uuid();
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
Realm.Sync.User.register('http://localhost:9080', username, 'password', (error ,user) => {
|
|
|
|
failOnError(error);
|
2016-11-29 09:51:26 +00:00
|
|
|
|
2016-11-11 17:16:40 +00:00
|
|
|
const clientA = new Realm({
|
|
|
|
path: 'testSynchronizeChangesWithTwoClientsAndOneUser_clientA.realm',
|
|
|
|
schema: schema,
|
|
|
|
sync: {
|
|
|
|
user: user,
|
|
|
|
url: 'http://localhost:9080/~/test',
|
|
|
|
},
|
|
|
|
});
|
2016-11-29 09:51:26 +00:00
|
|
|
|
2016-11-11 17:16:40 +00:00
|
|
|
const clientB = new Realm({
|
|
|
|
path: 'testSynchronizeChangesWithTwoClientsAndOneUser_clientB.realm',
|
|
|
|
schema: schema,
|
|
|
|
sync: {
|
|
|
|
user: user,
|
|
|
|
url: 'http://localhost:9080/~/test',
|
|
|
|
},
|
|
|
|
});
|
2016-11-29 09:51:26 +00:00
|
|
|
|
2016-11-11 17:16:40 +00:00
|
|
|
clientB.addListener('change', () => {
|
|
|
|
const foos = clientB.objects('Foo');
|
|
|
|
if (foos.length > 0) {
|
|
|
|
TestCase.assertEqual(foos.length, 1);
|
|
|
|
TestCase.assertEqual(foos[0].string, 'Hello, World!');
|
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
2016-11-29 09:51:26 +00:00
|
|
|
|
2016-11-11 17:16:40 +00:00
|
|
|
clientA.write(() => {
|
|
|
|
clientA.create('Foo', { string: 'Hello, World!' });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-11-29 09:51:26 +00:00
|
|
|
}, */
|
2016-11-11 17:16:40 +00:00
|
|
|
|
2016-11-08 16:59:30 +00:00
|
|
|
};
|
2017-10-16 21:51:47 +00:00
|
|
|
|