ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
28 lines (26 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const testHelpers_1 = require("./../testHelpers");
describe("Expression", () => {
// todo: this remove should be moved to be on decorators
describe("remove", () => {
describe("decorators", () => {
function doTest(text, removeIndex, expectedText) {
const { firstChild, sourceFile } = testHelpers_1.getInfoFromText(text);
firstChild.getDecorators()[0].getArguments()[removeIndex].remove();
chai_1.expect(sourceFile.getFullText()).to.equal(expectedText);
}
it("should remove a decorator argument at the start", () => {
doTest("@test(1, 2, 3)\nclass T {}", 0, "@test(2, 3)\nclass T {}");
});
it("should remove a decorator argument in the middle", () => {
doTest("@test(1, 2, 3)\nclass T {}", 1, "@test(1, 3)\nclass T {}");
});
it("should remove a decorator argument at the end", () => {
doTest("@test(1, 2, 3)\nclass T {}", 2, "@test(1, 2)\nclass T {}");
});
});
});
});
//# sourceMappingURL=expressionTests.js.map