80 lines
11 KiB
JavaScript
80 lines
11 KiB
JavaScript
"use strict";
|
|
require("typings-test");
|
|
var smartstring = require("../dist/index");
|
|
var should = require("should");
|
|
describe("smartstring", function () {
|
|
describe(".Domain class", function () {
|
|
var testDomain;
|
|
it("should create a new Domain object", function () {
|
|
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
|
|
testDomain.should.be.instanceof(smartstring.Domain);
|
|
});
|
|
it("should have a .topLevel", function () {
|
|
testDomain.topLevel.should.equal("level1D");
|
|
});
|
|
it("should have a .level2", function () {
|
|
testDomain.level2.should.equal("level2D");
|
|
});
|
|
it("should have a .level3", function () {
|
|
testDomain.level3.should.equal("level3D");
|
|
});
|
|
it("should have the correct dns zone name", function () {
|
|
testDomain.zoneName.should.equal("level2D.level1D");
|
|
});
|
|
it("should have the correct protocol", function () {
|
|
testDomain.protocol.should.equal("https");
|
|
});
|
|
});
|
|
describe(".Git class", function () {
|
|
var testGit;
|
|
it("should create a new Git class GitRepo", function () {
|
|
testGit = new smartstring.GitRepo("git+https://github.com/pushrocks/smartstring.git");
|
|
testGit.should.be.instanceof(smartstring.GitRepo);
|
|
});
|
|
it("should return a .host", function () {
|
|
testGit.host
|
|
.should.equal("github.com");
|
|
});
|
|
it("should return a .user", function () {
|
|
testGit.user
|
|
.should.equal("pushrocks");
|
|
});
|
|
it("should return a .repo", function () {
|
|
testGit.repo
|
|
.should.equal("smartstring");
|
|
});
|
|
it("should return a .httpsUrl", function () {
|
|
testGit.httpsUrl
|
|
.should.equal("https://github.com/pushrocks/smartstring.git");
|
|
});
|
|
it("should return a .sshUrl", function () {
|
|
testGit.sshUrl
|
|
.should.equal("git@github.com:pushrocks/smartstring.git");
|
|
});
|
|
});
|
|
describe(".docker", function () {
|
|
describe(".makeEnvObject", function () {
|
|
it("should create a Env Object", function () {
|
|
var envStringArray = ["VIRTUAL_HOST=sub.domain.tld", "DEFAULT_HOST=some.domain.com"];
|
|
var envObject = smartstring.docker.makeEnvObject(envStringArray);
|
|
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld");
|
|
envObject.DEFAULT_HOST.should.equal("some.domain.com");
|
|
});
|
|
});
|
|
});
|
|
describe(".typescript", function () {
|
|
describe(".referenceRegex", function () {
|
|
it("should match reference paths", function () {
|
|
smartstring.typescript.regexReferencePath.test("/// <reference path=\"\" />")
|
|
.should.be.true();
|
|
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
|
|
.should.be.true();
|
|
smartstring.typescript.regexReferencePath.test("/// <referencepath=\"\" />")
|
|
.should.be.false();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLElBQVksV0FBVyxXQUFNLGVBQWUsQ0FBQyxDQUFBO0FBQzdDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUUvQixRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsSUFBSSxVQUE2QixDQUFDO1FBQ2xDLEVBQUUsQ0FBQyxtQ0FBbUMsRUFBQztZQUNuQyxVQUFVLEdBQUcsSUFBSSxXQUFXLENBQUMsTUFBTSxDQUFDLGlDQUFpQyxDQUFDLENBQUM7WUFDdkUsVUFBVSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUN4RCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyx5QkFBeUIsRUFBQztZQUN6QixVQUFVLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDaEQsQ0FBQyxDQUFDLENBQ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l7XHJcbiAgICAgICAgICAgIHRlc3RHaXQucmVwb1xyXG4gICAgICAgICAgICAgICAgLnNob3VsZC5lcXVhbChcInNtYXJ0c3RyaW5nXCIpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIGl0KFwic2hvdWxkIHJldHVybiBhIC5odHRwc1VybFwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHRlc3RHaXQuaHR0cHNVcmxcclxuICAgICAgICAgICAgICAgIC5zaG91bGQuZXF1YWwoXCJodHRwczovL2dpdGh1Yi5jb20vcHVzaHJvY2tzL3NtYXJ0c3RyaW5nLmdpdFwiKTtcclxuICAgICAgICB9KTtcclxuICAgICAgICBpdChcInNob3VsZCByZXR1cm4gYSAuc3NoVXJsXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdGVzdEdpdC5zc2hVcmxcclxuICAgICAgICAgICAgICAgIC5zaG91bGQuZXF1YWwoXCJnaXRAZ2l0aHViLmNvbTpwdXNocm9ja3Mvc21hcnRzdHJpbmcuZ2l0XCIpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfSlcclxuICAgIGRlc2NyaWJlKFwiLmRvY2tlclwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgZGVzY3JpYmUoXCIubWFrZUVudk9iamVjdFwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGl0KFwic2hvdWxkIGNyZWF0ZSBhIEVudiBPYmplY3RcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICAgICAgbGV0IGVudlN0cmluZ0FycmF5ID0gW1wiVklSVFVBTF9IT1NUPXN1Yi5kb21haW4udGxkXCIsXCJERUZBVUxUX0hPU1Q9c29tZS5kb21haW4uY29tXCJdO1xyXG4gICAgICAgICAgICAgICAgbGV0IGVudk9iamVjdCA9IHNtYXJ0c3RyaW5nLmRvY2tlci5tYWtlRW52T2JqZWN0KGVudlN0cmluZ0FycmF5KTtcclxuICAgICAgICAgICAgICAgIGVudk9iamVjd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