'use strict';

var _mocha = require('mocha');

var _chai = require('chai');

var _supertest = require('supertest');

var _supertest2 = _interopRequireDefault(_supertest);

var _integrationSpecInt = require('../_integration.spec-int.js');

var _integrationSpecInt2 = _interopRequireDefault(_integrationSpecInt);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _mocha.describe)('BehaviorModifyOutgoingResponseHeader', function () {

    var opts = void 0;
    (0, _mocha.before)(function (done) {
        _integrationSpecInt2.default.config().then(function (papiOpts) {
            opts = papiOpts.behavior['modifyOutgoingResponseHeader.papi.json'];
            done();
        });
    });

    (0, _mocha.describe)('response header', function () {

        var request = (0, _supertest2.default)(_integrationSpecInt2.default.urlPrefix);

        (0, _mocha.it)('should return the expected header', function (done) {

            request.get(_integrationSpecInt2.default.testUrl('modifyOutgoingResponseHeader.papi.json')).expect(200).end(function (err, res) {
                (0, _chai.expect)(res.headers[opts.customHeaderName.toLowerCase()]).to.equal(opts.newHeaderValue, 'response header not set correctly');
                done();
            });
        });
    });
});