"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.callAfterCount = exports.countEvent = exports.testSISO = exports.testMIMO = void 0;
const assert = require("assert");
function testMIMO(unit, input, output) {
    unit.pushAll(input);
    assert.deepEqual(unit.takeAll(), output);
}
exports.testMIMO = testMIMO;
function testSISO(unit, inputName, input, outputName, output) {
    unit.push(inputName, input);
    assert.deepEqual(unit.peak(outputName), output);
}
exports.testSISO = testSISO;
function countEvent(emitter, event, callback) {
    const eventCounter = {
        count: 0,
        remove: () => {
            emitter.removeListener(event, listener);
        },
        reset: () => {
            eventCounter.count = 0;
        },
    };
    const listener = () => {
        eventCounter.count++;
        callback && callback(eventCounter.count);
    };
    emitter.addListener(event, listener);
    return eventCounter;
}
exports.countEvent = countEvent;
function callAfterCount(pin, event, max = 1000, callback) {
    const eventCounter = countEvent(pin, event, (count) => {
        if (count >= max) {
            callback();
        }
    });
    return eventCounter;
}
exports.callAfterCount = callAfterCount;
//# sourceMappingURL=util.js.map