-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommentStripper.spec.ts
More file actions
21 lines (20 loc) · 1.36 KB
/
CommentStripper.spec.ts
File metadata and controls
21 lines (20 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { parser } from "./index"
describe("CommentStripper", () => {
it.each([
{ label: "line comments stripped outside blocks", input: "value = kept // stripped\n" },
{ label: "block comments stripped outside blocks", input: "value = before /* stripped */ after\n" },
{ label: "http link is not treated as comment", input: "[http://example.com Example]" },
{ label: "comments are preserved in code blocks", input: "%%ts\nconst x = 1 // keep\n/* keep */\n%%\n" },
{ label: "comments are preserved in diagram blocks", input: "++\na // keep\n/* keep */\n++\n" }
] as const)("$label", ({ input }) =>
expect(parser.block.parse(input)?.map(node => node.toObject())).toMatchSnapshot())
it.each([
{ label: "line comments stripped outside blocks", input: "value = kept // stripped\n" },
{ label: "block comments stripped outside blocks", input: "value = before /* stripped */ after\n" },
{ label: "protocol text is preserved", input: "http://example.com\n" }
] as const)("$label", ({ input }) => expect(parser.parse(input)?.toObject()).toMatchSnapshot())
it.each([
{ label: "comments are preserved in code blocks", input: "%%ts\nconst x = 1 // keep\n/* keep */\n%%\n" },
{ label: "comments are preserved in diagram blocks", input: "++\na // keep\n/* keep */\n++\n" }
] as const)("$label", ({ input }) => expect(parser.parse(input)?.toObject()).toMatchSnapshot())
})