import { describe, it, expect, afterEach, vi } from 'vitest';
import { setEmailSender, getRegisteredEmailSender, resolveEmailSender } from '../../email/sender.js';
import { setActuateConfig } from '../../config/runtime.js';
afterEach(() => {
    setEmailSender(null);
    setActuateConfig(undefined);
});
describe('email sender registry', () => {
    it('round-trips a registered sender', () => {
        expect(getRegisteredEmailSender()).toBeNull();
        const sender = { send: vi.fn(async () => { }) };
        setEmailSender(sender);
        expect(getRegisteredEmailSender()).toBe(sender);
        setEmailSender(null);
        expect(getRegisteredEmailSender()).toBeNull();
    });
    it('resolves null when nothing is configured', () => {
        expect(resolveEmailSender()).toBeNull();
    });
    it('resolves the registered sender when no platform adapter is set', () => {
        const sender = { send: vi.fn(async () => { }) };
        setEmailSender(sender);
        expect(resolveEmailSender()).toBe(sender);
    });
    it('prefers the platform adapter over a registered sender', () => {
        const registered = { send: vi.fn(async () => { }) };
        const platform = { send: vi.fn(async () => { }) };
        setEmailSender(registered);
        setActuateConfig({ platform: { email: platform } });
        expect(resolveEmailSender()).toBe(platform);
    });
});
//# sourceMappingURL=sender.test.js.map