Skip to content

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

859 B
Raw Blame
// SPDX-License-Identifier: Apache-2.0

import { describe, it, expect } from 'bun:test';
import { epochMs } from '../../src/shared/epoch-ms.js';

describe('epochMs', () => {
  it('passes a milliseconds value through unchanged', () => {
    expect(epochMs(1_799_999_999_999)).toBe(1_799_999_999_999);
    expect(epochMs(Date.now())).toBe(Date.now());
  });

  it('multiplies a legacy seconds value up to milliseconds', () => {
    // 2025-06-01 in seconds, as a few hundred legacy rows stored it.
    expect(epochMs(1_748_745_600)).toBe(1_748_745_600_000);
  });

  it('uses the same 10^12 boundary as the SQL asMs fragment', () => {
    // 10^12 ms ≈ 2001-09-09; 10^12 s ≈ year 33658. Nothing plausible is ambiguous.
    expect(epochMs(999_999_999_999)).toBe(999_999_999_999_000);
    expect(epochMs(1_000_000_000_000)).toBe(1_000_000_000_000);
  });
});