forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomments.ts
32 lines (29 loc) · 1020 Bytes
/
comments.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as ts from "../_namespaces/ts.js";
describe("comment parsing", () => {
const withShebang = `#! node
/** comment */
// another one
;`;
const noShebang = `/** comment */
// another one
;`;
const withTrailing = `;/* comment */
// another one
`;
it("skips shebang", () => {
const result = ts.getLeadingCommentRanges(withShebang, 0);
assert.isDefined(result);
assert.strictEqual(result.length, 2);
});
it("treats all comments at start of file as leading comments", () => {
const result = ts.getLeadingCommentRanges(noShebang, 0);
assert.isDefined(result);
assert.strictEqual(result.length, 2);
});
it("returns leading comments if position is not 0", () => {
const result = ts.getLeadingCommentRanges(withTrailing, 1);
assert.isDefined(result);
assert.strictEqual(result.length, 1);
assert.strictEqual(result[0].kind, ts.SyntaxKind.SingleLineCommentTrivia);
});
});