mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
test(types): stop asserting Date.now() timestamps are deep-equal
createInitialRalphTrackerState() stamps lastActivity: Date.now(). The 'should create fresh instances each time' test deep-equaled two factory results, so two calls straddling a millisecond boundary differed by 1ms and failed intermittently (e.g. PR #139 CI: 1782927694581 vs ...580). Exclude the dynamic lastActivity from the equality check and assert it is a number separately, preserving the test's intent (distinct instances with identical initial field values) without the timing race.
This commit is contained in:
+8
-1
@@ -101,7 +101,14 @@ describe('types utility functions', () => {
|
|||||||
const state2 = createInitialRalphTrackerState();
|
const state2 = createInitialRalphTrackerState();
|
||||||
|
|
||||||
expect(state1).not.toBe(state2);
|
expect(state1).not.toBe(state2);
|
||||||
expect(state1).toEqual(state2);
|
// `lastActivity` is stamped with Date.now(), so two calls that straddle a
|
||||||
|
// millisecond boundary differ by 1ms. Compare the rest of the initial
|
||||||
|
// state for equality and assert the timestamp is a number separately.
|
||||||
|
const { lastActivity: lastActivity1, ...rest1 } = state1;
|
||||||
|
const { lastActivity: lastActivity2, ...rest2 } = state2;
|
||||||
|
expect(rest1).toEqual(rest2);
|
||||||
|
expect(typeof lastActivity1).toBe('number');
|
||||||
|
expect(typeof lastActivity2).toBe('number');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have correct types for all fields', () => {
|
it('should have correct types for all fields', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user