nope-js-node
Version:
NoPE Runtime for Nodejs. For Browser-Support please use nope-browser
71 lines (70 loc) • 5.13 kB
JavaScript
"use strict";
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @desc [description]
*/
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const mocha_1 = require("mocha");
const path_1 = require("./path");
(0, mocha_1.describe)("path", function () {
// Describe the required Test:
(0, mocha_1.describe)("getLeastCommonPathSegment", function () {
(0, mocha_1.it)("equal pathes", function () {
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/b"]), `getLeastCommonPathSegment(["a/b", "a/b"])`);
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/b/c"]), `getLeastCommonPathSegment("a/b", "a/b/c")`);
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b/c", "a/b", "a/b/d"]), `getLeastCommonPathSegment("a/b/c", "a/b")`);
chai_1.assert.equal("a", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/+"]), `getLeastCommonPathSegment(["a/b", "a/+"])`);
chai_1.assert.isFalse((0, path_1.getLeastCommonPathSegment)(["c/a", "a/+"]), "Pathes should be different");
});
(0, mocha_1.it)("equal pathes - singlelevel", function () {
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/b"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["a/b", "a/b"], { considerSingleLevel: true })`);
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/+"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["a/b", "a/+"], { considerSingleLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["a/b/c", "a/+/c"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["a/b/c", "a/+/c"], { considerSingleLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["+/b/c", "a/+/c"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["+/b/c", "a/+/c"], { considerSingleLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["+/+/+", "a/b/c"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment("+/+/+", "a/b/c", { considerSingleLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["+/b/+", "a/+/c"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["+/b/+", "a/+/c"], { considerSingleLevel: true })`);
chai_1.assert.equal("a/+/c", (0, path_1.getLeastCommonPathSegment)(["+/+/+", "a/+/c"], {
considerSingleLevel: true,
}), `getLeastCommonPathSegment(["+/+/+", "a/+/c"], { considerSingleLevel: true })`);
});
(0, mocha_1.it)("equal pathes - multilevel", function () {
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/b"], { considerMultiLevel: true }), `getLeastCommonPathSegment(["a/b", "a/b"], { considerMultiLevel: true }) == false`);
chai_1.assert.equal("a", (0, path_1.getLeastCommonPathSegment)(["a/b", "a/+"], { considerMultiLevel: true }), `getLeastCommonPathSegment(["a/b", "a/+"], { considerMultiLevel: true })`);
chai_1.assert.equal("a", (0, path_1.getLeastCommonPathSegment)(["a/b/c", "a/+/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["a/b/c", "a/+/c"], { considerMultiLevel: true })`);
chai_1.assert.equal(false, (0, path_1.getLeastCommonPathSegment)(["+/b/c", "a/+/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["+/b/c", "a/+/c"], { considerMultiLevel: true })`);
chai_1.assert.equal(false, (0, path_1.getLeastCommonPathSegment)(["+/+/+", "a/b/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["+/+/+", "a/b/c"], { considerMultiLevel: true })`);
chai_1.assert.equal(false, (0, path_1.getLeastCommonPathSegment)(["+/b/+", "a/+/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["+/b/+", "a/+/c"], { considerMultiLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["#", "a/b/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["#", "a/b/c"], { considerMultiLevel: true })`);
chai_1.assert.equal("a/b/c", (0, path_1.getLeastCommonPathSegment)(["a/#", "a/b/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["a/#", "a/b/c"], { considerMultiLevel: true })`);
chai_1.assert.equal("a/b", (0, path_1.getLeastCommonPathSegment)(["a/#", "a/b", "a/b/c"], {
considerMultiLevel: true,
}), `getLeastCommonPathSegment(["a/#", "a/b"], { considerMultiLevel: true })`);
});
});
});