"use strict";
/**
 *  Testing assets for ui/group
 *
 *  Copyright (C) 2010-2020 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework
 *
 *  Liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSut = exports.createRContext = exports.createStateManager = exports.createQuote = exports.createClassList = exports.createFeatureFlag = exports.getDomElement = exports.createJqueryContent = exports.createGroup = exports.createField = exports.createContext = exports.createBoxContent = exports.createContent = exports.createContainer = void 0;
var sinon = require('sinon');
exports.createContainer = function () {
    var container = {
        querySelectorAll: sinon.stub(),
        querySelector: sinon.stub(),
    };
    var dlist = {
        parentNode: { removeChild: function () { } },
    };
    container.querySelector.withArgs('dl').returns(dlist);
    return container;
};
exports.createContent = function (visible) {
    if (visible === void 0) { visible = false; }
    return {
        querySelector: sinon.stub(),
        querySelectorAll: sinon.stub(),
        getAttribute: sinon.stub().returns('foo'),
        classList: exports.createClassList(visible),
        addEventListener: sinon.stub(),
        getElementsByClassName: sinon.stub().returns([]),
    };
};
exports.createBoxContent = function () {
    var content = exports.createContent();
    content.querySelector = function () { return exports.createContent(); };
    return content;
};
exports.createContext = function () {
    return {
        createFieldCache: function () { },
        detachFields: function () { },
        detachStoreContent: function () { },
        hide: function () { },
        init: function () { },
        setOptions: function () { },
        setValueByName: function () { },
        show: function () { },
    };
};
exports.createField = function () {
    return {};
};
exports.createGroup = function (field_name, fields, cmatch_fields, is_internal, when_name) {
    if (fields === void 0) { fields = []; }
    if (cmatch_fields === void 0) { cmatch_fields = []; }
    if (is_internal === void 0) { is_internal = true; }
    if (when_name === void 0) { when_name = ''; }
    return {
        getIndexFieldName: sinon.stub().returns(field_name),
        getUserFieldNames: sinon.stub().returns(fields),
        getExclusiveFieldNames: sinon.stub().returns(fields),
        getExclusiveCmatchFieldNames: sinon.stub().returns(cmatch_fields),
        isInternal: sinon.stub().returns(is_internal),
        getWhenFieldName: sinon.stub().returns(when_name),
    };
};
exports.createJqueryContent = function () {
    return {
        show: sinon.stub(),
        hide: sinon.stub(),
        find: sinon.stub().returns({ live: sinon.stub() }),
        0: exports.getDomElement(),
        attr: sinon.stub(),
    };
};
exports.getDomElement = function () {
    return {
        getAttribute: sinon.stub().returns('foo'),
        querySelector: function () {
            return { classList: exports.createClassList() };
        },
        classList: exports.createClassList(),
    };
};
exports.createFeatureFlag = function () {
    return {
        isEnabled: function (_) {
            return false;
        },
    };
};
exports.createClassList = function (visible) {
    if (visible === void 0) { visible = false; }
    return {
        contains: sinon.stub().returns(visible),
        add: sinon.stub(),
        remove: sinon.stub(),
    };
};
exports.createQuote = function () {
    return {
        on: sinon.stub(),
        onClassifyAndNow: sinon.stub(),
        visitData: sinon.stub(),
        setData: sinon.stub(),
        getDataByName: sinon.stub(),
    };
};
exports.createStateManager = function () {
    return {
        is: sinon.stub(),
        observes: sinon.stub(),
        processDataAttributes: sinon.stub(),
    };
};
exports.createRContext = function () {
    return {
        getFieldByName: function () {
            return {
                revokeStyle: function () { },
                applyStyle: function () { },
            };
        },
    };
};
/**
 * Create new SUT
 *
 * @param  Sut   - target Sut
 * @param  input - mock content
 *
 * @return system under test
 */
exports.createSut = function (Sut, input) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j;
    if (input === void 0) { input = {}; }
    var $content = (_a = input.$content) !== null && _a !== void 0 ? _a : exports.createJqueryContent();
    var field = (_b = input.field) !== null && _b !== void 0 ? _b : exports.createField();
    var group = (_c = input.group) !== null && _c !== void 0 ? _c : exports.createGroup(field);
    var content = (_d = input.content) !== null && _d !== void 0 ? _d : exports.createContent();
    var jquery = sinon.stub().withArgs(content).returns($content);
    var context = (_e = input.context) !== null && _e !== void 0 ? _e : exports.createContext();
    var rcontext = (_f = input.rcontext) !== null && _f !== void 0 ? _f : exports.createRContext();
    var feature_flag = (_g = input.feature_flag) !== null && _g !== void 0 ? _g : exports.createFeatureFlag();
    var styler = (_h = input.styler) !== null && _h !== void 0 ? _h : null;
    var state_manager = (_j = input.state_manager) !== null && _j !== void 0 ? _j : exports.createStateManager();
    return new Sut(group, content, styler, jquery, context, rcontext, null, feature_flag, state_manager);
};
//# sourceMappingURL=data:application/json;base64, 