gecko/services/sync/tests/unit/test_tracker_addChanged.js
Gregory Szorc 7ece058f3d Bug 785225 - Part 9: Refactor engines to not use singletons; r=rnewman
Engines now maintain a reference to the service they belong to. This
allows them to obtain references to other engine instances belonging to
that service and that service only.

Stores and trackers now maintain a reference to the engine they belong
to.

Engine managers now maintain a reference back to a service.

The clients singleton has been removed. It now exists as an instance
variable on Service. Parts of ClientsEngine do behave as singletons
(e.g. commands). This will be addressed in future refactoring.
2012-08-29 14:43:41 -07:00

31 lines
908 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
function run_test() {
let tracker = new Tracker("Tracker", Service);
let id = "the_id!";
_("Make sure nothing exists yet..");
do_check_eq(tracker.changedIDs[id], null);
_("Make sure adding of time 0 works");
tracker.addChangedID(id, 0);
do_check_eq(tracker.changedIDs[id], 0);
_("A newer time will replace the old 0");
tracker.addChangedID(id, 10);
do_check_eq(tracker.changedIDs[id], 10);
_("An older time will not replace the newer 10");
tracker.addChangedID(id, 5);
do_check_eq(tracker.changedIDs[id], 10);
_("Adding without time defaults to current time");
tracker.addChangedID(id);
do_check_true(tracker.changedIDs[id] > 10);
tracker._lazySave.clear()
}