'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)('CriteriaMatchVariable', function () {

    (0, _mocha.describe)('exact match', function () {

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

        (0, _mocha.it)('should trigger behaviors if matches expression', function (done) {

            request.get(_integrationSpecInt2.default.testUrl('matchVariable.match.papi.json', 'criteria')).expect(200).end(function (err, res) {
                (0, _chai.expect)(res.headers[_integrationSpecInt2.default.checkHeaderName.toLowerCase()]).to.equal(_integrationSpecInt2.default.checkHeaderValue, 'match expression failed');
                done();
            });
        });
    });

    (0, _mocha.describe)('match one of', function () {

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

        (0, _mocha.it)('should trigger behaviors if any value matches', function (done) {

            request.get(_integrationSpecInt2.default.testUrl('matchVariable.oneOf.papi.json', 'criteria')).expect(200).end(function (err, res) {
                (0, _chai.expect)(res.headers[_integrationSpecInt2.default.checkHeaderName.toLowerCase()]).to.equal(_integrationSpecInt2.default.checkHeaderValue, 'match one of failed');
                done();
            });
        });
    });

    (0, _mocha.describe)('number between', function () {

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

        (0, _mocha.it)('should trigger behaviors if var is in numeric range', function (done) {

            request.get(_integrationSpecInt2.default.testUrl('matchVariable.between.papi.json', 'criteria')).expect(200).end(function (err, res) {
                (0, _chai.expect)(res.headers[_integrationSpecInt2.default.checkHeaderName.toLowerCase()]).to.equal(_integrationSpecInt2.default.checkHeaderValue, 'var within range failed');
                done();
            });
        });
    });
});