-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgetJsdocBlockDescriptionSource.test.mjs
More file actions
79 lines (71 loc) · 1.87 KB
/
getJsdocBlockDescriptionSource.test.mjs
File metadata and controls
79 lines (71 loc) · 1.87 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { deepStrictEqual, throws } from "assert";
import { parse } from "comment-parser";
import snapshot from "snapshot-assertion";
import COMMENT_PARSER_OPTIONS from "./COMMENT_PARSER_OPTIONS.mjs";
import getJsdocBlockDescriptionSource from "./getJsdocBlockDescriptionSource.mjs";
export default (tests) => {
tests.add(
"`getJsdocBlockDescriptionSource` with argument 1 `jsdocBlock` not an object.",
() => {
throws(() => {
getJsdocBlockDescriptionSource(true);
}, new TypeError("Argument 1 `jsdocBlock` must be an object."));
}
);
tests.add(
"`getJsdocBlockDescriptionSource` with no description, tag.",
() => {
const [jsdocBlock] = parse("/**@a*/", {
...COMMENT_PARSER_OPTIONS,
startLine: 1,
});
deepStrictEqual(getJsdocBlockDescriptionSource(jsdocBlock), []);
}
);
tests.add(
"`getJsdocBlockDescriptionSource` with a description, no tags.",
async () => {
const [jsdocBlock] = parse(
`/**
* Line 1.
* Line 2.
*/`,
{
...COMMENT_PARSER_OPTIONS,
startLine: 1,
}
);
await snapshot(
JSON.stringify(getJsdocBlockDescriptionSource(jsdocBlock), null, 2),
new URL(
"./test/snapshots/getJsdocBlockDescriptionSource/description-no-tags.json",
import.meta.url
)
);
}
);
tests.add(
"`getJsdocBlockDescriptionSource` with a description, tags.",
async () => {
const [jsdocBlock] = parse(
`/**
* Line 1.
* Line 2.
* @a
* @b
*/`,
{
...COMMENT_PARSER_OPTIONS,
startLine: 1,
}
);
await snapshot(
JSON.stringify(getJsdocBlockDescriptionSource(jsdocBlock), null, 2),
new URL(
"./test/snapshots/getJsdocBlockDescriptionSource/description-tags.json",
import.meta.url
)
);
}
);
};