UNPKG

akamai-nginx

Version:

generate nginx config from akamai property

69 lines (55 loc) 2.82 kB
'use strict'; var _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert); var _mocha = require('mocha'); var _matchVariable = require('../../src/criteria/matchVariable.js'); var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } (0, _mocha.describe)('CriteriaMatchVariable', function () { (0, _mocha.describe)('exact match', function () { (0, _mocha.it)('should return expected lua', function (done) { _fs2.default.readFile(__dirname + '/matchVariable.match.papi.json', 'utf8', function (err, options) { if (err) { throw err; } var opts = JSON.parse(options); var expected = 'getVar("' + opts.variableName + '") == swapVars("' + opts.variableExpression + '")'; var criteria = new _matchVariable.CriteriaMatchVariable(opts); var actual = criteria.process(true); _assert2.default.equal(actual, expected); done(); }); }); }); (0, _mocha.describe)('match one of', function () { (0, _mocha.it)('should return expected lua', function (done) { _fs2.default.readFile(__dirname + '/matchVariable.oneOf.papi.json', 'utf8', function (err, options) { if (err) { throw err; } var opts = JSON.parse(options); var expected = 'matches(getVar("' + opts.variableName + '"), swapVars("' + opts.variableValues[0] + '"))' + ' or matches(getVar("' + opts.variableName + '"), swapVars("' + opts.variableValues[1] + '"))'; var criteria = new _matchVariable.CriteriaMatchVariable(opts); var actual = criteria.process(true); _assert2.default.equal(actual, expected); done(); }); }); }); (0, _mocha.describe)('number between', function () { (0, _mocha.it)('should return expected lua', function (done) { _fs2.default.readFile(__dirname + '/matchVariable.between.papi.json', 'utf8', function (err, options) { if (err) { throw err; } var opts = JSON.parse(options); var expected = '(getVarNumber("' + opts.variableName + '") > tonumber("' + opts.lowerBound + '")' + ' and getVarNumber("' + opts.variableName + '") < tonumber("' + opts.upperBound + '"))'; var criteria = new _matchVariable.CriteriaMatchVariable(opts); var actual = criteria.process(true); _assert2.default.equal(actual, expected); done(); }); }); }); });