'use strict';

var _assert = require('assert');

var _assert2 = _interopRequireDefault(_assert);

var _mocha = require('mocha');

var _rewriteUrl = require('../../src/behaviors/rewriteUrl.js');

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

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

(0, _mocha.describe)('BehaviorRewriteUrl', function () {
    (0, _mocha.describe)('replace path part', function () {
        (0, _mocha.it)('should return expected lua', function (done) {
            _fs2.default.readFile(__dirname + '/rewriteUrl.replace.papi.json', 'utf8', function (err, options) {
                if (err) {
                    throw err;
                }
                var opts = JSON.parse(options);

                var expected = ['-- ' + opts.behavior + ' path part', 'aka_origin_url = string.gsub(aka_request_path, "' + opts.match + '", "' + opts.targetPath + '")', 'if true == ' + opts.keepQueryString + ' then', '\taka_origin_url = aka_origin_url .. aka_request_qs', 'end'];

                var actual = new _rewriteUrl.BehaviorRewriteUrl(opts).process();

                _assert2.default.equal(actual[0], expected[0]);
                _assert2.default.equal(actual[1], expected[1]);
                done();
            });
        });
    });
});