ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
28 lines (26 loc) • 1.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const testHelpers_1 = require("./../testHelpers");
describe("JSDoc", () => {
describe("remove", () => {
function doTest(text, index, jsDocIndex, expectedText) {
const { sourceFile } = testHelpers_1.getInfoFromText(text);
sourceFile.getFunctions()[index].getDocumentationCommentNodes()[jsDocIndex].remove();
chai_1.expect(sourceFile.getFullText()).to.equal(expectedText);
}
it("should remove the js doc", () => {
doTest("enum I {}\n\n/** Test */\nfunction func() {}", 0, 0, "enum I {}\n\nfunction func() {}");
});
it("should remove the js doc when first", () => {
doTest("enum I {}\n\n/** first */\n/** second */\nfunction func() {}", 0, 0, "enum I {}\n\n/** second */\nfunction func() {}");
});
it("should remove the js doc when in the middle", () => {
doTest("enum I {}\n\n/** first */\n/** second */\n/** third */\nfunction func() {}", 0, 1, "enum I {}\n\n/** first */\n/** third */\nfunction func() {}");
});
it("should remove the js doc when last", () => {
doTest("enum I {}\n\n/** first */\n/** second */\nfunction func() {}", 0, 1, "enum I {}\n\n/** first */\nfunction func() {}");
});
});
});
//# sourceMappingURL=jsdocTests.js.map