Skip to content

Commit b8d7a2f

Browse files
committed
add tests
1 parent 11837f0 commit b8d7a2f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/testRunner/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"unittests/extractTestHelpers.ts",
4040
"unittests/tsserverProjectSystem.ts",
4141
"unittests/typingsInstaller.ts",
42-
42+
4343
"unittests/asserts.ts",
4444
"unittests/base64.ts",
4545
"unittests/builder.ts",
@@ -54,6 +54,7 @@
5454
"unittests/extractConstants.ts",
5555
"unittests/extractFunctions.ts",
5656
"unittests/extractRanges.ts",
57+
"unittests/factory.ts",
5758
"unittests/hostNewLineSupport.ts",
5859
"unittests/incrementalParser.ts",
5960
"unittests/initializeTSConfig.ts",

src/testRunner/unittests/factory.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace ts {
2+
describe("FactoryAPI", () => {
3+
describe("createArrowFunction", () => {
4+
it("parenthesizes concise body if necessary", () => {
5+
function checkBody(body: ConciseBody) {
6+
const node = createArrowFunction(
7+
/*modifiers*/ undefined,
8+
/*typeParameters*/ undefined,
9+
[],
10+
/*type*/ undefined,
11+
/*equalsGreaterThanToken*/ undefined,
12+
body,
13+
);
14+
assert.strictEqual(node.body.kind, SyntaxKind.ParenthesizedExpression);
15+
}
16+
17+
checkBody(createObjectLiteral());
18+
checkBody(createPropertyAccess(createObjectLiteral(), "prop"));
19+
checkBody(createAsExpression(createPropertyAccess(createObjectLiteral(), "prop"), createTypeReferenceNode("T", /*typeArguments*/ undefined)));
20+
checkBody(createNonNullExpression(createPropertyAccess(createObjectLiteral(), "prop")));
21+
});
22+
});
23+
});
24+
}

0 commit comments

Comments
 (0)