webpack/test/Template.unittest.js

28 lines
673 B
JavaScript
Raw Normal View History

2017-01-18 23:17:10 +08:00
"use strict";
const Template = require("../lib/Template");
2017-01-18 23:17:10 +08:00
describe("Template", () => {
2018-01-24 20:17:21 +08:00
it("should generate valid identifiers", () => {
expect(Template.toIdentifier("0abc-def9")).toBe("_0abc_def9");
});
2017-01-18 23:17:10 +08:00
it("should generate valid number identifiers", () => {
const items = [];
let item;
2018-02-25 18:46:17 +08:00
for (let i = 0; i < 80; i += 1) {
item = Template.numberToIdentifier(i);
2018-01-24 20:17:21 +08:00
expect(item).not.toBe("");
expect(items).not.toContain(item);
items.push(item);
}
});
// cspell:ignore sdfas sadfome
it("should generate sanitized path identifiers", () => {
2018-02-25 18:46:17 +08:00
expect(Template.toPath("path/to-sdfas/sadfome$$.js")).toBe(
"path-to-sdfas-sadfome$$-js"
);
});
});