UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

30 lines (28 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const testHelpers_1 = require("./../testHelpers"); describe("BodiedNode", () => { describe("setBodyText", () => { function doTest(startCode, newText, expectedCode) { const { firstChild, sourceFile } = testHelpers_1.getInfoFromText(startCode); firstChild.setBodyText(newText); chai_1.expect(sourceFile.getFullText()).to.equal(expectedCode); } // most of these tests are in bodyableNodeTests it("should set the body text", () => { doTest("namespace identifier {}", "var myVar;", "namespace identifier {\n var myVar;\n}"); }); }); describe("fill", () => { function doTest(startCode, structure, expectedCode) { const { firstChild, sourceFile } = testHelpers_1.getInfoFromText(startCode); firstChild.fill(structure); chai_1.expect(firstChild.getText()).to.equal(expectedCode); } it("should set the text", () => { doTest("namespace identifier {\n}", { bodyText: "var myVar;" }, "namespace identifier {\n var myVar;\n}"); }); }); }); //# sourceMappingURL=bodiedNodeTests.js.map