import QueueManager from './QueueManager';
import { of } from 'rxjs';
import { QueueStrategy } from './QueueStrategy';
jest.mock('../backend/services/DeferredDbSaver/DeferredDbSaver');
jest.mock('../ipfs/utils/ipfsCacheDb');
jest.mock('src/services/ipfs/utils/cluster.ts', () => ({ add: jest.fn() }));
jest.mock('src/services/backend/channels/BroadcastChannelSender');
const mockFetchIpfsContent = jest.fn();
jest.mock('src/services/ipfs/utils/utils-ipfs.ts', () => ({
    ipfsCacheDb: jest.fn(),
    cyberCluster: jest.fn(),
    fetchIpfsContent: mockFetchIpfsContent,
    addContenToIpfs: jest.fn(),
}));
const TIMEOUT_MS = 300;
const queueStrategy = new QueueStrategy({
    db: { timeout: TIMEOUT_MS, maxConcurrentExecutions: 2 },
    node: { timeout: TIMEOUT_MS, maxConcurrentExecutions: 2 },
    gateway: { timeout: TIMEOUT_MS, maxConcurrentExecutions: 2 },
}, ['db', 'node', 'gateway']);
const cid1 = 'cid1';
const cid2 = 'cid1';
const cid3 = 'cid1';
jest.useFakeTimers();
describe('QueueManager', () => {
    let queueManager;
    let mockNode;
    beforeEach(() => {
        const deferredDbSaverMock = {
            enqueueIpfsContent: jest.fn(),
            enqueueLinks: jest.fn(),
        };
        queueManager = new QueueManager(of(mockNode), {
            strategy: queueStrategy,
            queueDebounceMs: 0,
            defferedDbSaver: deferredDbSaverMock,
        });
    });
    afterEach(() => {
    });
    test('should instantiate without errors', () => {
        expect(queueManager).toBeInstanceOf(QueueManager);
    });
    test('should enqueue item', (done) => {
        queueManager.enqueue(cid1, (cid, status, source) => {
            expect(cid).toBe(cid1);
            expect(status).toBe('pending');
            expect(source).toBe('db');
            done();
        });
    });
});
//# sourceMappingURL=q.test.js.map