UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

40 lines (38 loc) 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const compiler_1 = require("./../../../../compiler"); const testHelpers_1 = require("./../../testHelpers"); // todo: make tests in other files reusable for StatementedNode. Then retest everything within namespaces and functions. describe("StatementedNode", () => { describe("getting a declaration within a namespace", () => { const { firstChild } = testHelpers_1.getInfoFromText("namespace Namespace1 {\n class Class1 {}\n}\n"); const classes = firstChild.getClasses(); it("should have the expected number of classes", () => { chai_1.expect(classes.length).to.equal(1); }); it("should have correct type", () => { chai_1.expect(classes[0]).to.be.instanceOf(compiler_1.ClassDeclaration); }); }); describe("getting a declaration within a namespace with dot tokens", () => { const { firstChild } = testHelpers_1.getInfoFromText("namespace Namespace1.Namespace2.Namespace3 { class MyClass {} }\n"); const classes = firstChild.getClasses(); it("should have the expected number of classes", () => { chai_1.expect(classes.length).to.equal(1); }); }); it("should get items inside a namespace", () => { // only need to check for one kind in here const { firstChild } = testHelpers_1.getInfoFromText("namespace Identifier { function function1() {}\nfunction function2() {} }"); const functions = firstChild.getFunctions(); chai_1.expect(functions.length).to.equal(2); }); it("should get items inside a function", () => { // only need to check for one kind in here const { firstChild } = testHelpers_1.getInfoFromText("function Identifier() { function function1() {}\nfunction function2() {} }"); const functions = firstChild.getFunctions(); chai_1.expect(functions.length).to.equal(2); }); }); //# sourceMappingURL=generalTests.js.map