tests: migrate Date.now patching to the pinned-clock parameter
The now parameter (and partialGraph.now) replaced the need for global Date.now patching in tests. The ttl-expiry parity campaign's module-scope patch and the relational-comparator Time-Based Decay tests' before/after patches now pass the clock explicitly through check options — no global mutation, no restore-order fragility, and the pinned-clock cache bypass keeps every evaluation honest. No stale references to the removed compiled evaluator or useCompiled option remain in the test suite.
This commit is contained in:
@@ -23,9 +23,7 @@ const TTL = 5000;
|
||||
const DOCS = 2;
|
||||
const docKey = (i) => `doc:${i}`;
|
||||
|
||||
const realNow = Date.now;
|
||||
let engineNow = 1_000_000_000_000;
|
||||
Date.now = () => engineNow;
|
||||
|
||||
function makeWrapper(disableCaching) {
|
||||
const arbiter = new Arbiter(disableCaching ? { disableCaching: true } : {});
|
||||
@@ -69,7 +67,7 @@ function makeWrapper(disableCaching) {
|
||||
return { ok: true, now: engineNow };
|
||||
},
|
||||
check(doc) {
|
||||
const result = arbiter.check('user:alice', 'premium', docKey(doc));
|
||||
const result = arbiter.check('user:alice', 'premium', docKey(doc), { now: engineNow });
|
||||
const b = balance.get(doc);
|
||||
const p = price.get(doc);
|
||||
const bFresh = b !== undefined && engineNow - b.ts <= TTL;
|
||||
|
||||
Reference in New Issue
Block a user