Tinytest.add("timesync - tick check - normal tick", function(test) {
  var lastTime = 5000;
  var currentTime = 6000;
  var interval = 1000;
  var tolerance = 1000;

  test.equal(SyncInternals.timeCheck(lastTime, currentTime, interval, tolerance), true);
});

Tinytest.add("timesync - tick check - slightly off", function(test) {
  var lastTime = 5000;
  var currentTime = 6500;
  var interval = 1000;
  var tolerance = 1000;

  test.equal(SyncInternals.timeCheck(lastTime, currentTime, interval, tolerance), true);

  currentTime = 5500;

  test.equal(SyncInternals.timeCheck(lastTime, currentTime, interval, tolerance), true);
});

Tinytest.add("timesync - tick check - big jump", function(test) {
  var lastTime = 5000;
  var currentTime = 0;
  var interval = 1000;
  var tolerance = 1000;

  test.equal(SyncInternals.timeCheck(lastTime, currentTime, interval, tolerance), false);

  currentTime = 10000;

  test.equal(SyncInternals.timeCheck(lastTime, currentTime, interval, tolerance), false);
});

/*
  TODO: add tests for proper dependencies in reactive functions
 */

@@ -1068,8 +1068,630 @@
 ons%0A */%0A
+%0ATinytest.addAsync(%22timesync - basic - initial sync%22, function(test, next) %7B%0A%0A  function success() %7B%0A    var syncedTime = TimeSync.serverTime();%0A%0A    // Make sure the time exists%0A    test.isTrue(syncedTime);%0A%0A    // Make sure it's close to the current time on the client. This should%0A    // always be true in PhantomJS tests where client/server are the same%0A    // machine, although it might fail in development environments.%0A    test.isTrue( Math.abs(syncedTime - Date.now()) %3C 1000 );%0A%0A    next();%0A  %7D%0A%0A  function fail() %7B%0A    test.fail();%0A    next();%0A  %7D%0A%0A  simplePoll(TimeSync.isSynced, success, fail, 5000, 100);%0A%7D);%0A

add a test to ensure basic syncing on startup works