"use strict";
/**
 * Test case for FieldResetter
 *
 *  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 });
var FieldResetter_1 = require("../../src/client/FieldResetter");
var chai_1 = require("chai");
var CommonResources_1 = require("./CommonResources");
describe('FieldResetter', function () {
    it('reset fields to empty string by default', function () {
        var _a = getClient(), client = _a.client, program = _a.program;
        var sut = new FieldResetter_1.FieldResetter(client);
        program.hasNaField = function () { return true; };
        program.clearNaFields = true;
        var data = { some_field: ['0'] };
        var expected = { some_field: [''] };
        chai_1.expect(sut.reset(data)).to.deep.equal(expected);
    });
    it("don't reset fields to empty string by default when clearNaFields is disabled", function () {
        var _a = getClient(), client = _a.client, program = _a.program;
        var sut = new FieldResetter_1.FieldResetter(client);
        program.hasNaField = function () { return true; };
        program.clearNaFields = false;
        var data = { some_field: ['0'] };
        var expected = { some_field: ['default'] };
        chai_1.expect(sut.reset(data)).to.deep.equal(expected);
    });
    it('reset fields to their own default value', function () {
        var client = getClient().client;
        var sut = new FieldResetter_1.FieldResetter(client);
        var data = { some_field: ['0'] };
        var expected = { some_field: ['default'] };
        chai_1.expect(sut.reset(data)).to.deep.equal(expected);
    });
});
var getClient = function (step) {
    if (step === void 0) { step = null; }
    var quote = CommonResources_1.createStubClientQuote();
    var ui = CommonResources_1.createStubUi(step);
    var program = CommonResources_1.createStubProgram({ defaults: { some_field: 'default' } });
    return {
        client: CommonResources_1.createStubClient(quote, ui, program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