"use strict";
/**
 * Tests error context
 *
 *  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 Affero 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 Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
var sut = require("../../src/error/ContextError");
var chai_1 = require("chai");
describe('ContextError', function () {
    it('can be created with generic error', function () {
        var context = { foo: 'context' };
        chai_1.expect(sut.context(new Error('test error'), context).context).to.equal(context);
    });
    it('provides type predicate for TypeScript', function () {
        var context = { bar: 'baz context' };
        // force to Error to discard ContextError type
        var e = sut.context(new Error('test error'), context);
        if (sut.hasContext(e)) {
            // if isChained was properly defined, then outer should now
            // have type ChainedError, and so this should compile
            chai_1.expect(e.context).to.equal(context);
        }
        else {
            chai_1.expect.fail();
        }
    });
    it('can create typed contexts', function () {
        // this is the actual test
        var e = sut.context(new Error('test error'), { foo: 'context' });
        // contravariance check (would fail to compile)
        chai_1.expect(sut.hasContext(e)).to.be.true;
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29udGV4dEVycm9yVGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIkNvbnRleHRFcnJvclRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHOztBQUVILGtEQUFvRDtBQUNwRCw2QkFBNEI7QUFFNUIsUUFBUSxDQUFDLGNBQWMsRUFBRTtJQUN2QixFQUFFL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