add tests

This commit is contained in:
Klaus Meinhardt
2018-07-02 17:44:32 +02:00
parent 11837f0109
commit b8d7a2f763
2 changed files with 26 additions and 1 deletions

View File

@@ -39,7 +39,7 @@
"unittests/extractTestHelpers.ts",
"unittests/tsserverProjectSystem.ts",
"unittests/typingsInstaller.ts",
"unittests/asserts.ts",
"unittests/base64.ts",
"unittests/builder.ts",
@@ -54,6 +54,7 @@
"unittests/extractConstants.ts",
"unittests/extractFunctions.ts",
"unittests/extractRanges.ts",
"unittests/factory.ts",
"unittests/hostNewLineSupport.ts",
"unittests/incrementalParser.ts",
"unittests/initializeTSConfig.ts",

View File

@@ -0,0 +1,24 @@
namespace ts {
describe("FactoryAPI", () => {
describe("createArrowFunction", () => {
it("parenthesizes concise body if necessary", () => {
function checkBody(body: ConciseBody) {
const node = createArrowFunction(
/*modifiers*/ undefined,
/*typeParameters*/ undefined,
[],
/*type*/ undefined,
/*equalsGreaterThanToken*/ undefined,
body,
);
assert.strictEqual(node.body.kind, SyntaxKind.ParenthesizedExpression);
}
checkBody(createObjectLiteral());
checkBody(createPropertyAccess(createObjectLiteral(), "prop"));
checkBody(createAsExpression(createPropertyAccess(createObjectLiteral(), "prop"), createTypeReferenceNode("T", /*typeArguments*/ undefined)));
checkBody(createNonNullExpression(createPropertyAccess(createObjectLiteral(), "prop")));
});
});
});
}