'use strict';

var _assert = require('assert');

var _assert2 = _interopRequireDefault(_assert);

var _mocha = require('mocha');

var _requestMethod = require('../../src/criteria/requestMethod.js');

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

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

(0, _mocha.describe)('CriteriaRequestMethod', function () {
    (0, _mocha.describe)('check is method', function () {
        (0, _mocha.it)('should return expected lua', function (done) {
            _fs2.default.readFile(__dirname + '/requestMethod.is.papi.json', 'utf8', function (err, options) {
                if (err) {
                    throw err;
                }
                var opts = JSON.parse(options);

                var expected = 'ngx.req.get_method() == swapVars("' + opts.value + '")';

                var criteria = new _requestMethod.CriteriaRequestMethod(opts);
                var actual = criteria.process();
                _assert2.default.equal(actual, expected);
                done();
            });
        });
    });
    (0, _mocha.describe)('check is not method', function () {
        (0, _mocha.it)('should return expected lua', function (done) {
            _fs2.default.readFile(__dirname + '/requestMethod.not.papi.json', 'utf8', function (err, options) {
                if (err) {
                    throw err;
                }
                var opts = JSON.parse(options);

                var expected = 'ngx.req.get_method() ~= swapVars("' + opts.value + '")';
                var criteria = new _requestMethod.CriteriaRequestMethod(opts);
                var actual = criteria.process();
                _assert2.default.equal(actual, expected);
                done();
            });
        });
    });
});