"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const factory_1 = require("../../../src/providers/chain-state/external/adapters/factory");
const config_1 = __importDefault(require("../../../src/config"));
describe('AdapterFactory', function () {
    const savedExternalProviders = config_1.default.externalProviders;
    before(function () {
        config_1.default.externalProviders = { ...savedExternalProviders, alchemy: { apiKey: 'test-key' } };
    });
    after(function () {
        config_1.default.externalProviders = savedExternalProviders;
    });
    it('should throw for unknown provider', function () {
        (0, chai_1.expect)(() => factory_1.AdapterFactory.createAdapter({ name: 'unknown', priority: 1 })).to.throw('Unknown indexed API provider');
    });
    it('should register and create a custom adapter', function () {
        class TestAdapter {
            constructor() {
                this.name = 'Test';
            }
        }
        factory_1.AdapterFactory.registerAdapter('test', TestAdapter);
        const adapter = factory_1.AdapterFactory.createAdapter({ name: 'test', priority: 1 });
        (0, chai_1.expect)(adapter.name).to.eq('Test');
        factory_1.AdapterFactory.registerAdapter('test', undefined);
    });
    it('should list moralis and alchemy as supported providers', function () {
        const providers = factory_1.AdapterFactory.getSupportedProviders();
        (0, chai_1.expect)(providers).to.include('alchemy');
        (0, chai_1.expect)(providers).to.include('moralis');
    });
    it('should be case-insensitive for provider names', function () {
        const adapter = factory_1.AdapterFactory.createAdapter({ name: 'Alchemy', priority: 1 });
        (0, chai_1.expect)(adapter).to.exist;
    });
});
//# sourceMappingURL=factory.test.js.map