md-toy-blog
Version:
Very simple Markdown blog: serves your md as html without fancy databases. You will only spend time writing the actual data.
57 lines (56 loc) • 3.78 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("../bootstrap");
var chai_1 = require("chai");
var path_1 = __importDefault(require("path"));
var moduleOrClonedRepo_1 = __importDefault(require("../../src/utils/moduleOrClonedRepo"));
describe('/utils/moduleOrClonedRepo.ts', function () {
describe("check if path could be within node module", function () {
it('should be true when ends in "/node_modules/<anything>"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathWithinCouldBeNodeModule("/hi/md-toy-blog/build/test/unit/node_modules/dir_dir/asdf")).to.be.equal(true);
});
it('should be true when ends in "/node_modules/<anything>/more"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathWithinCouldBeNodeModule("/hi/md-toy-blog/build/test/unit/node_modules/dir_dir/asdf/hello")).to.be.equal(true);
});
it('should be false when ends in "/node_modules/"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathWithinCouldBeNodeModule("/hi/md-toy-blog/build/test/unit/node_modules/")).to.be.equal(false);
});
it('should be false when not contains "/node_modules/"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathWithinCouldBeNodeModule("/hi/md-toy-blog/build/test/unit/not_modulos/hey")).to.be.equal(false);
});
});
describe("check if path could be a node module's root dir", function () {
it('should be true when ends in "/node_modules/<anything>"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathCouldBeNodeModuleRootDir("/hi/md-toy-blog/build/test/unit/node_modules/dir_dir")).to.be.equal(true);
});
it('should be false when ends in "/node_modules/<anything>/more"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathCouldBeNodeModuleRootDir("/hi/md-toy-blog/build/test/unit/node_modules/dir_dir/asdf/hello")).to.be.equal(false);
});
it('should be false when ends in "/node_modules/"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathCouldBeNodeModuleRootDir("/hi/md-toy-blog/build/test/unit/node_modules/")).to.be.equal(false);
});
it('should be false when not contains "/node_modules/"', function () {
chai_1.expect(moduleOrClonedRepo_1.default.pathCouldBeNodeModuleRootDir("/hi/md-toy-blog/build/test/unit/not_modulos/hey")).to.be.equal(false);
});
});
describe("get could be path of a node module's root dir", function () {
it('should be same as abs input minus rest when "/node_modules/<anything></rest>"', function () {
var rest = "/asdf/hello";
var p = "/hi/md-toy-blog/build/../test/unit/node_modules/dir_dir" + rest;
var absP = path_1.default.resolve(p);
var absMinusRest = absP.substr(0, absP.length - rest.length);
chai_1.expect(moduleOrClonedRepo_1.default.getCouldBeNodeModuleRootDir(p)).to.be.equal(absMinusRest);
});
it('should throw when ends in "/node_modules/"', function () {
var p = "/hi/md-toy-blog/build/test/unit/node_modules/";
chai_1.expect(function () { return moduleOrClonedRepo_1.default.getCouldBeNodeModuleRootDir(p); }).to.throw;
});
it('should throw when not contains "/node_modules/"', function () {
var p = "/hi/md-toy-blog/build/test/unit/not_modulos/hey";
chai_1.expect(function () { return moduleOrClonedRepo_1.default.getCouldBeNodeModuleRootDir(p); }).to.throw;
});
});
});