feat: replace browser login with imported Reddit sessions
This commit is contained in:
1 parent
2b0545afcf
commit
c483c7b8be
76 files changed
+2048
-2828
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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('login-required')).toBe(false);
|
||||
expect(start).not.toHaveBeenCalled();
|
||||
|
||||
expect(runtime.reconcile('authenticated')).toBe(true);
|
||||
expect(runtime.reconcile('authenticated')).toBe(true);
|
||||
expect(start).toHaveBeenCalledOnce();
|
||||
|
||||
expect(runtime.reconcile('login-required')).toBe(false);
|
||||
expect(stop).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it.each(['unknown', 'login-required', 'unreachable'] as const)(
|
||||
'treats %s as waiting for an extension dump',
|
||||
(state) => {
|
||||
const runtime = new SessionBoundRuntime(vi.fn(), vi.fn());
|
||||
expect(runtime.reconcile(state)).toBe(false);
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user