ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
32 lines (30 loc) • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const testHelpers_1 = require("./../testHelpers");
describe("TypeAliasDeclaration", () => {
describe("fill", () => {
function doTest(code, structure, expectedCode) {
const { firstChild, sourceFile } = testHelpers_1.getInfoFromText(code);
firstChild.fill(structure);
chai_1.expect(sourceFile.getFullText()).to.equal(expectedCode);
}
it("should not change the when nothing is set", () => {
doTest("type Identifier = string;", {}, "type Identifier = string;");
});
it("should change the property when setting", () => {
doTest("type Identifier = string;", { type: "number" }, "type Identifier = number;");
});
});
describe("remove", () => {
function doTest(text, index, expectedText) {
const { sourceFile } = testHelpers_1.getInfoFromText(text);
sourceFile.getTypeAliases()[index].remove();
chai_1.expect(sourceFile.getFullText()).to.equal(expectedText);
}
it("should remove the type alias declaration", () => {
doTest("type I = 1;\ntype J = 2;\ntype K = 3;", 1, "type I = 1;\ntype K = 3;");
});
});
});
//# sourceMappingURL=typeAliasDeclarationTests.js.map