docxtemplater
Version:
.docx generator working with templates and data (like Mustache)
39 lines (37 loc) • 1.42 kB
JavaScript
;
var Lexer = require("../lexer.js");
var testUtils = require("./utils");
var expect = testUtils.expect;
var fixtures = require("./fixtures");
var FileTypeConfig = require("../file-type-config");
var docxconfig = FileTypeConfig.docx;
var inspectModule = require("./inspect-module.js");
var tagsDocxConfig = {
text: docxconfig.tagsXmlTextArray,
other: docxconfig.tagsXmlLexedArray
};
describe("Algorithm", function () {
Object.keys(fixtures).forEach(function (key) {
var fixture = fixtures[key];
it(fixture.it, function () {
var doc = testUtils.makeDocx(key, fixture.content);
doc.setOptions({ delimiters: fixture.delimiters });
var iModule = inspectModule();
doc.attachModule(iModule);
doc.setData(fixture.scope);
doc.render();
expect(iModule.inspect.lexed).to.be.deep.equal(fixture.lexed, "Lexed incorrect");
expect(iModule.inspect.parsed).to.be.deep.equal(fixture.parsed, "Parsed incorrect");
if (fixture.postparsed) {
expect(iModule.inspect.postparsed).to.be.deep.equal(fixture.postparsed, "Postparsed incorrect");
}
if (iModule.inspect.content) {
expect(iModule.inspect.content).to.be.deep.equal(fixture.result, "Content incorrect");
}
});
});
it("should xmlparse strange tags", function () {
var result = Lexer.xmlparse(fixtures.strangetags.content, tagsDocxConfig);
expect(result).to.be.deep.equal(fixtures.strangetags.xmllexed);
});
});