Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

656 B
Raw Blame
import { describe, it, expect, vi, afterEach } from 'vitest';
import { sleep } from './sleep.js';

afterEach(() => {
  vi.useRealTimers();
});

describe('sleep', () => {
  it('resolves after the requested delay', async () => {
    vi.useFakeTimers();
    let settled = false;
    const pending = sleep(500).then(() => { settled = true; });

    await vi.advanceTimersByTimeAsync(499);
    expect(settled).toBe(false);

    await vi.advanceTimersByTimeAsync(1);
    await pending;
    expect(settled).toBe(true);
  });

  it('resolves with undefined', async () => {
    await expect(sleep(0)).resolves.toBeUndefined();
  });
});
// @vitest-environment node