2017-01-18 23:17:10 +08:00
|
|
|
"use strict";
|
2014-08-04 22:25:33 +08:00
|
|
|
|
2017-11-15 21:08:11 +08:00
|
|
|
require("should");
|
2014-08-04 22:25:33 +08:00
|
|
|
|
2017-08-26 04:34:05 +08:00
|
|
|
const Template = require("../lib/Template");
|
2017-01-18 23:17:10 +08:00
|
|
|
|
|
|
|
describe("Template", () => {
|
|
|
|
it("should generate valid identifiers", () =>
|
2017-09-06 15:39:28 +08:00
|
|
|
Template.toIdentifier("0abc-def9").should.equal("_0abc_def9"));
|
2017-01-18 23:17:10 +08:00
|
|
|
it("should generate valid number identifiers", () => {
|
|
|
|
const items = [];
|
|
|
|
let item;
|
|
|
|
for(let i = 0; i < 80; i += 1) {
|
2017-08-26 04:34:05 +08:00
|
|
|
item = Template.numberToIdentifer(i);
|
2017-01-18 23:17:10 +08:00
|
|
|
if(item === "") {
|
|
|
|
throw new Error("empty number identifier");
|
2016-02-08 22:59:09 +08:00
|
|
|
} else if(items.indexOf(item) > -1) {
|
2017-01-18 23:17:10 +08:00
|
|
|
throw new Error("duplicate number identifier");
|
2016-02-08 22:59:09 +08:00
|
|
|
} else {
|
|
|
|
items.push(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-08-26 04:34:05 +08:00
|
|
|
it("should generate sanitized path identifiers", () => {
|
|
|
|
Template.toPath("path/to-sdfas/sadfome$$.js").should.equal("path-to-sdfas-sadfome$$-js");
|
|
|
|
});
|
2014-08-04 22:25:33 +08:00
|
|
|
});
|