UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

38 lines (36 loc) 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const testHelpers_1 = require("./../testHelpers"); describe("ExpressionWithTypeArguments", () => { function getFirstExpressionWithTypeArgs(text) { const { firstChild } = testHelpers_1.getInfoFromText(text); return firstChild.getExtends(); } describe("getExpression", () => { it("should get the compiler expression", () => { const expression = getFirstExpressionWithTypeArgs("class MyClass extends MyOtherClass {}"); chai_1.expect(expression.getExpression().getText()).to.equal("MyOtherClass"); }); }); describe("getTypeArguments", () => { it("should return an empty array when there's no type arguments", () => { const expression = getFirstExpressionWithTypeArgs("class MyClass extends MyOtherClass {}"); chai_1.expect(expression.getTypeArguments().length).to.equal(0); }); describe("having two type arguments", () => { const expression = getFirstExpressionWithTypeArgs("class MyClass extends MyOtherClass<string, number> {}"); const typeArgs = expression.getTypeArguments(); it("should return the right number of type arguments", () => { chai_1.expect(typeArgs.length).to.equal(2); }); it("should first have a string", () => { chai_1.expect(typeArgs[0].getText()).to.equal("string"); }); it("should second have a number", () => { chai_1.expect(typeArgs[1].getText()).to.equal("number"); }); }); }); }); //# sourceMappingURL=expressionWithTypeArgumentsTests.js.map