Files
RedditBot/tests/session-bound-runtime.test.ts
T

26 lines
902 B
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { SessionBoundRuntime } from '../src/services/session-bound-runtime.js';
describe('SessionBoundRuntime', () => {
it('starts account work only when authenticated and stops it on logout', () => {
const start = vi.fn();
const stop = vi.fn();
const runtime = new SessionBoundRuntime(start, stop);
expect(runtime.reconcile(false)).toBe(false);
expect(start).not.toHaveBeenCalled();
expect(runtime.reconcile(true)).toBe(true);
expect(runtime.reconcile(true)).toBe(true);
expect(start).toHaveBeenCalledOnce();
expect(runtime.reconcile(false)).toBe(false);
expect(stop).toHaveBeenCalledOnce();
});
it('treats incomplete authentication as waiting for an extension dump', () => {
const runtime = new SessionBoundRuntime(vi.fn(), vi.fn());
expect(runtime.reconcile(false)).toBe(false);
});
});