write some tests
This commit is contained in:
parent
3d3b07b7cb
commit
34d6df0923
51
dist/smartstring.indent.js
vendored
51
dist/smartstring.indent.js
vendored
@ -1,24 +1,57 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var splitString = function (stringArg) {
|
var splitString = function (stringArg) {
|
||||||
var stringArray = [];
|
return stringArg.split("\n");
|
||||||
return stringArray;
|
|
||||||
};
|
};
|
||||||
var joinString = function (stringArrayArg) {
|
var joinString = function (stringArrayArg) {
|
||||||
var localString = "";
|
var resultString = "";
|
||||||
for (var _i = 0, stringArrayArg_1 = stringArrayArg; _i < stringArrayArg_1.length; _i++) {
|
for (var _i = 0, stringArrayArg_1 = stringArrayArg; _i < stringArrayArg_1.length; _i++) {
|
||||||
var line = stringArrayArg_1[_i];
|
var line = stringArrayArg_1[_i];
|
||||||
localString = localString + line + "\n";
|
resultString = resultString + line + "\n";
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
return localString;
|
return resultString;
|
||||||
|
};
|
||||||
|
var cleanStringArray = function (stringArrayArg) {
|
||||||
|
var testRegex = /^[\s]*$/;
|
||||||
|
if (testRegex.test(stringArrayArg[0])) {
|
||||||
|
stringArrayArg.shift();
|
||||||
|
}
|
||||||
|
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
|
||||||
|
stringArrayArg.pop();
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return stringArrayArg;
|
||||||
};
|
};
|
||||||
exports.indent = function (stringArg, spaceAmount) {
|
exports.indent = function (stringArg, spaceAmount) {
|
||||||
return;
|
var resultString;
|
||||||
|
return resultString;
|
||||||
};
|
};
|
||||||
exports.indentWithPrefix = function (stringArg, prefixArg) {
|
exports.indentWithPrefix = function (stringArg, prefixArg) {
|
||||||
return;
|
var resultString;
|
||||||
|
return resultString;
|
||||||
};
|
};
|
||||||
exports.deIndent = function (stringArg) {
|
exports.deIndent = function (stringArg) {
|
||||||
return;
|
var resultString;
|
||||||
|
var splitStringArray = splitString(stringArg);
|
||||||
|
splitStringArray = cleanStringArray(splitStringArray);
|
||||||
|
var minCommonLeftOffset;
|
||||||
|
var deIndentRegex = /^(\s*)/;
|
||||||
|
for (var _i = 0, splitStringArray_1 = splitStringArray; _i < splitStringArray_1.length; _i++) {
|
||||||
|
var stringItem = splitStringArray_1[_i];
|
||||||
|
var offsetString = deIndentRegex.exec(stringItem)[1];
|
||||||
|
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset) {
|
||||||
|
minCommonLeftOffset = offsetString.length;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
var resultSplitStringArray = [];
|
||||||
|
for (var _a = 0, splitStringArray_2 = splitStringArray; _a < splitStringArray_2.length; _a++) {
|
||||||
|
var stringItem = splitStringArray_2[_a];
|
||||||
|
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
resultString = joinString(resultSplitStringArray);
|
||||||
|
return resultString;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxVQUFDLFNBQWdCO0lBQy9CLElBQUksV0FBVyxHQUFZLEVBQUUsQ0FBQztJQUU5QixNQUFNLENBQUMsV0FBVyxDQUFDO0FBRXZCLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLFVBQUMsY0FBdUI7SUFDckMsSUFBSSxXQUFXLEdBQVUsRUFBRSxDQUFDO0lBQzVCLEdBQUcsQ0FBQSxDQUFhLFVBQWMsRUFBZCxpQ0FBYyxFQUFkLDRCQUFjLEVBQWQsSUFBYyxDQUFDO1FBQTNCLElBQUksSUFBSSx1Q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QUcsUUFBUSxDQUFDO0lBQzdCLEdBQUcsQ0FBQSxDQUFtQixVQUFnQixFQUFoQixxQ0FBZ0IsRUFBaEIsOEJBQWdCLEVBQWhCLElBQWdCLENBQUM7UUFBbkMsSUFBSSxVQUFVLHlCQUFBO1FBQ2QsSUFBSSxZQUFZLEdBQUcsYUFBYSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNyRCxFQUFFLENBQUMsQ0FBQyxPQUFPLG1CQUFtQixJQUFJLFdBQVcsSUFBSSxZQUFZLENBQUMsTUFBTSxHQUFHLG1CQUFtQixDQUFDLENBQUEsQ0FBQztZQUN4RixtQkFBbUIsR0FBRyxZQUFZLENBQUMsTUFBTSxDQUFDO1FBQzlDLENBQUM7UUFBQSxDQUFDO0tBQ0w7SUFBQSxDQUFDO0lBQ0YsSUFBSSxzQkFBc0IsR0FBRyxFQUFFLENBQUM7SUFDaEMsR0FBRyxDQUFBLENBQW1CLFVBQWdCLEVBQWhCLHFDQUFnQixFQUFoQiw4QkFBZ0IsRUFBaEIsSUFBZ0IsQ0FBQztRQUFuQyxJQUFJLFVBQVUseUJBQUE7UUFDZCxzQkFBc0IsQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDLENBQUM7S0FDdkU7SUFBQSxDQUFDO0lBQ0YsWUFBWSxHQUFHLFVBQVUsQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDO0lBQ2xELE1BQU0sQ0FBQyxZQUFZLENBQUM7QUFDeEIsQ0FBQyxDQUFBIn0=
|
11
test/test.js
11
test/test.js
@ -68,6 +68,15 @@ describe("smartstring", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe(".indent", function () {
|
||||||
|
describe(".deIndent()", function () {
|
||||||
|
it("should deindent a string", function () {
|
||||||
|
var testString = "\n base\n should be indented\n some more\n base\n indented\n ";
|
||||||
|
testString = smartstring.indent.deIndent(testString);
|
||||||
|
console.log(testString);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
describe(".typescript", function () {
|
describe(".typescript", function () {
|
||||||
describe(".referenceRegex", function () {
|
describe(".referenceRegex", function () {
|
||||||
it("should match reference paths", function () {
|
it("should match reference paths", function () {
|
||||||
@ -81,4 +90,4 @@ describe("smartstring", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLElBQVksV0FBVyxXQUFNLGVBQWUsQ0FBQyxDQUFBO0FBQzdDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUUvQixRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsSUFBSSxVQUE2QixDQUFDO1FBQ2xDLElBQUksV0FBOEIsQ0FBQztRQUNuQyxFQUFFLENBQUMsbUNBQW1DLEVBQUM7WUFDbkMsVUFBVSxHQUFHLElBQUksV0FBVyxDQUFDLE1BQU0sQ0FBQyxpQ0FBaUMsQ0FBQyxDQUFDO1lBQ3ZFLFVBQVUsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUM7WUFDcEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUM1QixDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyx5QkFBeUIsRUFBQztZQUN6QixVQUFVLENBQUMsUUFBUSxDQUFDLE1BQU0s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TixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUMifQ==
|
21
test/test.ts
21
test/test.ts
@ -67,7 +67,26 @@ describe("smartstring",function(){
|
|||||||
envObject.DEFAULT_HOST.should.equal("some.domain.com");
|
envObject.DEFAULT_HOST.should.equal("some.domain.com");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
|
describe(".indent",function(){
|
||||||
|
let testString = `
|
||||||
|
base
|
||||||
|
should be indented
|
||||||
|
some more
|
||||||
|
base
|
||||||
|
indented
|
||||||
|
`;
|
||||||
|
describe(".deIndent()",function(){
|
||||||
|
it("should deindent a string",function(){
|
||||||
|
testString = smartstring.indent.deIndent(testString);
|
||||||
|
console.log(testString);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(".indentWithPrefix",function(){
|
||||||
|
it("should indent")
|
||||||
|
})
|
||||||
|
});
|
||||||
describe(".typescript",function(){
|
describe(".typescript",function(){
|
||||||
describe(".referenceRegex",function(){
|
describe(".referenceRegex",function(){
|
||||||
it("should match reference paths",function(){
|
it("should match reference paths",function(){
|
||||||
|
@ -10,6 +10,17 @@ let joinString = (stringArrayArg:string[]):string => {
|
|||||||
resultString = resultString + line + "\n";
|
resultString = resultString + line + "\n";
|
||||||
};
|
};
|
||||||
return resultString;
|
return resultString;
|
||||||
|
};
|
||||||
|
|
||||||
|
let cleanStringArray = (stringArrayArg:string[]):string[] => {
|
||||||
|
let testRegex = /^[\s]*$/;
|
||||||
|
if(testRegex.test(stringArrayArg[0])){
|
||||||
|
stringArrayArg.shift();
|
||||||
|
}
|
||||||
|
if(testRegex.test(stringArrayArg[stringArrayArg.length - 1])){
|
||||||
|
stringArrayArg.pop();
|
||||||
|
};
|
||||||
|
return stringArrayArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let indent = (stringArg:string,spaceAmount:number):string => {
|
export let indent = (stringArg:string,spaceAmount:number):string => {
|
||||||
@ -25,6 +36,7 @@ export let indentWithPrefix = (stringArg:string,prefixArg:string):string => {
|
|||||||
export let deIndent = (stringArg:string):string => {
|
export let deIndent = (stringArg:string):string => {
|
||||||
let resultString:string;
|
let resultString:string;
|
||||||
let splitStringArray:string[] = splitString(stringArg);
|
let splitStringArray:string[] = splitString(stringArg);
|
||||||
|
splitStringArray = cleanStringArray(splitStringArray);
|
||||||
let minCommonLeftOffset:number;
|
let minCommonLeftOffset:number;
|
||||||
let deIndentRegex = /^(\s*)/;
|
let deIndentRegex = /^(\s*)/;
|
||||||
for(let stringItem of splitStringArray){
|
for(let stringItem of splitStringArray){
|
||||||
|
Loading…
Reference in New Issue
Block a user