UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

28 lines (26 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const testHelpers_1 = require("./../testHelpers"); describe("VariableStatement", () => { describe("remove", () => { function doTest(text, index, expectedText) { const { sourceFile } = testHelpers_1.getInfoFromText(text); sourceFile.getVariableDeclarations()[index].remove(); chai_1.expect(sourceFile.getFullText()).to.equal(expectedText); } it("should remove the statement when the only declaration", () => { doTest("const t = '';\nconst v = '';\nconst u = '';", 1, "const t = '';\nconst u = '';"); }); it("should remove the variable declaration when the first", () => { doTest("const t = 1, u = 2;", 0, "const u = 2;"); }); it("should remove the variable declaration when in the middle", () => { doTest("const t = 1, u = 2, v = 3;", 1, "const t = 1, v = 3;"); }); it("should remove the variable declaration when the last", () => { doTest("const t = 1, u = 2;", 1, "const t = 1;"); }); }); }); //# sourceMappingURL=variableDeclarationTests.js.map