Skip to content

Commit 3a84c02

Browse files
committed
add tests
1 parent bfdb1cc commit 3a84c02

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace ts {
2+
describe("FactoryAPI", () => {
3+
describe("createExportAssignment", () => {
4+
it("parenthesizes default export if necessary", () => {
5+
function checkExpression(expression: Expression) {
6+
const node = createExportAssignment(
7+
/*decorators*/ undefined,
8+
/*modifiers*/ undefined,
9+
/*isExportEquals*/ false,
10+
expression,
11+
);
12+
assert.strictEqual(node.expression.kind, SyntaxKind.ParenthesizedExpression);
13+
}
14+
15+
const clazz = createClassExpression(/*modifiers*/ undefined, "C", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [
16+
ts.createProperty(/*decorators*/ undefined, [ts.createToken(ts.SyntaxKind.StaticKeyword)], "prop", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, ts.createLiteral("1")),
17+
]);
18+
checkExpression(clazz);
19+
checkExpression(createPropertyAccess(clazz, "prop"));
20+
21+
const func = createFunctionExpression(/*modifiers*/ undefined, /*asteriskToken*/ undefined, "fn", /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.createBlock([]));
22+
checkExpression(func);
23+
checkExpression(createCall(func, /*typeArguments*/ undefined, /*argumentsArray*/ undefined));
24+
25+
checkExpression(createBinary(createLiteral("a"), SyntaxKind.CommaToken, createLiteral("b")));
26+
checkExpression(createCommaList([createLiteral("a"), createLiteral("b")]));
27+
});
28+
});
29+
});
30+
}

0 commit comments

Comments
 (0)