This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
forked from stephenh/ts-proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils-test.ts
57 lines (52 loc) · 1.64 KB
/
utils-test.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { maybeAddComment } from "../src/utils";
import { Code, joinCode } from "ts-poet";
describe("utils", () => {
describe("maybeAddComment", () => {
it("handles single-line impl comments", () => {
// Foo
const chunks: Code[] = [];
maybeAddComment({ leadingComments: " Foo\n" }, chunks);
expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`);
});
it("handles single-dot star comments", () => {
// /* Foo */
const chunks: Code[] = [];
maybeAddComment({ leadingComments: " Foo " }, chunks);
expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`);
});
it("handles single-line double-dot star comments", () => {
// /** Foo */
const chunks: Code[] = [];
maybeAddComment({ leadingComments: " * Foo " }, chunks);
expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`);
});
it("handles double-line double-dot star comments", () => {
// /**
// * Foo
// *
// * bar.
// */
const chunks: Code[] = [];
maybeAddComment({ leadingComments: "*\n Foo\n \n bar.\n" }, chunks);
expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`
"/**
* Foo
*
* bar.
*/"
`);
});
it("handles double-line impl comments", () => {
// // Foo
// // Bar
const chunks: Code[] = [];
maybeAddComment({ leadingComments: " Foo\n Bar\n" }, chunks);
expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`
"/**
* Foo
* Bar
*/"
`);
});
});
});