'use strict';

var _assert = require('assert');

var _assert2 = _interopRequireDefault(_assert);

var _mocha = require('mocha');

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

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

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

(0, _mocha.describe)('Criteria', function () {
    (0, _mocha.describe)('process', function () {
        (0, _mocha.describe)('match multiple patterns', function () {
            (0, _mocha.it)('should return expected lua', function (done) {
                _fs2.default.readFile(__dirname + '/criteria.multi.papi.json', 'utf8', function (err, options) {
                    if (err) {
                        throw err;
                    }
                    var opts = JSON.parse(options);

                    var expected = 'matches(ngx.test, swapVars("' + opts.values[0] + '")) or matches(ngx.test, swapVars("' + opts.values[1] + '"))';

                    _criteria.Criteria.register('testCriteria', _criteria.Criteria);
                    var criteria = _criteria.Criteria.create('testCriteria', opts);
                    criteria.checkVar = 'ngx.test';
                    criteria.options = opts;
                    var actual = criteria.process();
                    _assert2.default.equal(actual, expected);
                    done();
                });
            });
        });
        (0, _mocha.describe)('not equal single value', function () {
            (0, _mocha.it)('should return expected lua', function (done) {
                _fs2.default.readFile(__dirname + '/criteria.single.papi.json', 'utf8', function (err, options) {
                    if (err) {
                        throw err;
                    }
                    var opts = JSON.parse(options);

                    var expected = 'ngx.test ~= swapVars("' + opts.value + '")';

                    _criteria.Criteria.register('testCriteria', _criteria.Criteria);
                    var criteria = _criteria.Criteria.create('testCriteria', opts);
                    criteria.checkVar = 'ngx.test';
                    criteria.options = opts;
                    var actual = criteria.process();
                    _assert2.default.equal(actual, expected);
                    done();
                });
            });
        });
    });
});