"use strict";
/**
 * Test case for TableCellFieldContext
 *
 *  Copyright (C) 2010-2019 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 });
var TableCellFieldContext_1 = require("../../../src/ui/context/TableCellFieldContext");
var chai_1 = require("chai");
before(function () {
    this.jsdom = require('jsdom-global')();
});
after(function () {
    this.jsdom();
});
describe('TableCellFieldContext', function () {
    it('show sets visible to true', function () {
        var group = getGroupContent();
        var content = group.querySelector('#q_table_row_0');
        var sut = new TableCellFieldContext_1.TableCellFieldContext(document, getStylerStub(), 'q_field_0', content);
        var to = document.createElement('tr');
        sut.show(to, null);
        chai_1.expect(sut.isVisible()).to.be.true;
    });
    it('shows field and attaches to DOM when show is called for cloned content', function () {
        // Mock that the content has no parent, so is not attached
        var content = document.createElement('td');
        var sut = new TableCellFieldContext_1.TableCellFieldContext(document, getStylerStub(), 'foo_bar', content);
        chai_1.expect(sut.isAttached()).to.be.false;
        var to = document.createElement('tr');
        sut.show(to, null);
        chai_1.expect(sut.isAttached()).to.be.true;
        chai_1.expect(sut.isVisible()).to.be.true;
    });
    it('hide sets visible to false', function () {
        var group = getGroupContent();
        var content = group.querySelector('#q_table_row_0');
        var sut = new TableCellFieldContext_1.TableCellFieldContext(document, getStylerStub(), 'q_foo_row_0', content);
        sut.hide();
        chai_1.expect(sut.isVisible()).to.be.false;
    });
});
function getStylerStub() {
    return {
        setValue: function (_, __) { },
    };
}
function getGroupContent() {
    // Mock group content
    var group = document.createElement('div');
    group.innerHTML =
        '<table>' +
            '<tr id="q_table_row_0">' +
            '<td>' +
            '<input type="text" id="q_foo_row_0">' +
            '</td>' +
            '<td>' +
            '<div>' +
            '<label>' +
            '<input type="checkbox" data-field-name="table_row"> No' +
            '</label>' +
            '</div>' +
            '</td>' +
            '</tr>' +
            '</table>';
    return group;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVGFibGVDZWxsRmllbGRDb250ZXh0VGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIlRhYmxlQ2VsbEZpZWxkQ29udGV4dFRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHOztBQUVILHVGQUEyRjtBQUkzRiw2QkFBNEI7QUFFNUIsTUFBTSxDQUFDO0lBQ0wsSUFBSSxDQUFDLEtBQUssR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQztBQUN6QyxDQUFDLENBQUMsQ0FBQztBQUVILEtBQUssQ0FBQztJQUNKLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUNmLENBQUMsQ0FBQyxDQUFDO0FBRUgsUUFBUSxDQUFDLHVCQUF1QixFQUFFO0lBQ2hDLEVBQUUsQ0FBQywyQkFBMkIsRUFBRTtRQUM5QixJQUFNLEtBQUssR0FBRyxlQUFlLEVBQUUsQ0FBQztRQUVoQyxJQUFNLE9BQU8sR0FBRyxLQUFLLENBQUMsYUFBYSxDQUFDLGdCQUFnQixDQUFDLENBQUM7UUFDdEQsSUFBTSxHQUFHLEdBQUcsSUFBSSw2Q0FBRyxDQUNqQixRQUFRLEVBQ1IsYUFBYSxFQUFFLEVBQ2YsV0FBVyxFQUNLLE9BQU8sQ0FDeEIsQ0FBQztRQUVGLElBQU0sRUFBRSxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsSUF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