ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
31 lines (29 loc) • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const testHelpers_1 = require("./../testHelpers");
describe("NamespaceChildableNode", () => {
describe("getParentNamespace", () => {
it("should get the parent namespace when not using dot notation", () => {
const { firstChild } = testHelpers_1.getInfoFromText("namespace MyNamespace { class MyClass {} }");
chai_1.expect(firstChild.getClasses()[0].getParentNamespace()).to.equal(firstChild);
});
it("should get the parent namespace when using dot notation", () => {
const { firstChild } = testHelpers_1.getInfoFromText("namespace MyNamespace.MyOtherNamespace { class MyClass {} }");
chai_1.expect(firstChild.getClasses()[0].getParentNamespace()).to.equal(firstChild);
});
it("should get the parent namespace when using dot notation with the module keyword", () => {
const { firstChild } = testHelpers_1.getInfoFromText("module MyNamespace.MyOtherNamespace { class MyClass {} }");
chai_1.expect(firstChild.getClasses()[0].getParentNamespace()).to.equal(firstChild);
});
it("should get the parent namespace for variable statements", () => {
const { firstChild } = testHelpers_1.getInfoFromText("namespace MyNamespace.MyOtherNamespace { const v; }");
chai_1.expect(firstChild.getVariableStatements()[0].getParentNamespace()).to.equal(firstChild);
});
it("should return undefined when not in a namespace", () => {
const { firstChild } = testHelpers_1.getInfoFromText("namespace MyNamespace.MyOtherNamespace { }");
chai_1.expect(firstChild.getParentNamespace()).to.equal(undefined);
});
});
});
//# sourceMappingURL=namespaceChildableNode.js.map