var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import DeferredDbSaver from './DeferredDbSaver';
import { BehaviorSubject } from 'rxjs';
const nextTick = () => {
    return new Promise((resolve) => {
        setTimeout(resolve, 0);
    });
};
describe('DeferredDbSaver', () => {
    const dbApiMock$ = new BehaviorSubject(undefined);
    const deferredDbSaver = new DeferredDbSaver(dbApiMock$);
    it('should enqueue IPFS content', () => __awaiter(void 0, void 0, void 0, function* () {
        const content = {
            cid: 'Qm1234567890',
            textPreview: 'Hello, World!',
            source: 'node',
            meta: { size: 123, mime: 'text/plain', type: 'file' },
        };
        deferredDbSaver.enqueueIpfsContent(content);
        deferredDbSaver.enqueueIpfsContent(Object.assign(Object.assign({}, content), { cid: 'Qm1111' }));
        expect(deferredDbSaver.queue.size).toBe(2);
        const queueItem = deferredDbSaver.queue.get(content === null || content === void 0 ? void 0 : content.cid);
        expect(queueItem).toBeDefined();
        dbApiMock$.next({});
        expect(deferredDbSaver.queue.size).toBe(0);
        return Promise.resolve();
    }));
});
//# sourceMappingURL=DeferredDbSaver.test.js.map