Skip to content

Commit 54e1f5f

Browse files
committed
Testcase coverage of import *, fixes #333. Also coverage of example caption
1 parent e467f12 commit 54e1f5f

File tree

6 files changed

+237
-6
lines changed

6 files changed

+237
-6
lines changed

test/fixture/es6-import.input.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import multiply from "./es6.input.js";
2+
import * as foo from "some-other-module";
23

34
/**
45
* This function returns the number one.

test/fixture/es6-import.output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,26 +644,26 @@
644644
],
645645
"loc": {
646646
"start": {
647-
"line": 3,
647+
"line": 4,
648648
"column": 0
649649
},
650650
"end": {
651-
"line": 6,
651+
"line": 7,
652652
"column": 3
653653
}
654654
},
655655
"context": {
656656
"loc": {
657657
"start": {
658-
"line": 7,
658+
"line": 8,
659659
"column": 0
660660
},
661661
"end": {
662-
"line": 7,
662+
"line": 8,
663663
"column": 43
664664
}
665665
},
666-
"code": "import multiply from \"./es6.input.js\";\n\n/**\n * This function returns the number one.\n * @returns {Number} numberone\n */\nvar multiplyTwice = (a) => a * multiply(a);\n\nexport default multiplyTwice;\n"
666+
"code": "import multiply from \"./es6.input.js\";\nimport * as foo from \"some-other-module\";\n\n/**\n * This function returns the number one.\n * @returns {Number} numberone\n */\nvar multiplyTwice = (a) => a * multiply(a);\n\nexport default multiplyTwice;\n"
667667
},
668668
"errors": [],
669669
"returns": [
@@ -683,7 +683,7 @@
683683
{
684684
"title": "param",
685685
"name": "a",
686-
"lineNumber": 7
686+
"lineNumber": 8
687687
}
688688
],
689689
"members": {

test/fixture/example-caption.input.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* This function returns the number one.
3+
* @returns {Number} numberone
4+
* @example <caption>demonstrates how to run foo</caption>
5+
* foo(1);
6+
*/
7+
function foo() {
8+
// this returns 1
9+
return 1;
10+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"description": "This function returns the number one.",
4+
"tags": [
5+
{
6+
"title": "returns",
7+
"description": "numberone",
8+
"lineNumber": 2,
9+
"type": {
10+
"type": "NameExpression",
11+
"name": "Number"
12+
}
13+
},
14+
{
15+
"title": "example",
16+
"description": "foo(1);",
17+
"lineNumber": 3,
18+
"caption": "demonstrates how to run foo"
19+
}
20+
],
21+
"loc": {
22+
"start": {
23+
"line": 1,
24+
"column": 0
25+
},
26+
"end": {
27+
"line": 6,
28+
"column": 3
29+
}
30+
},
31+
"context": {
32+
"loc": {
33+
"start": {
34+
"line": 7,
35+
"column": 0
36+
},
37+
"end": {
38+
"line": 10,
39+
"column": 1
40+
}
41+
},
42+
"code": "/**\n * This function returns the number one.\n * @returns {Number} numberone\n * @example <caption>demonstrates how to run foo</caption>\n * foo(1);\n */\nfunction foo() {\n // this returns 1\n return 1;\n}\n"
43+
},
44+
"errors": [],
45+
"returns": [
46+
{
47+
"title": "returns",
48+
"description": "numberone",
49+
"lineNumber": 2,
50+
"type": {
51+
"type": "NameExpression",
52+
"name": "Number"
53+
}
54+
}
55+
],
56+
"examples": [
57+
{
58+
"title": "example",
59+
"description": "foo(1);",
60+
"lineNumber": 3,
61+
"caption": "demonstrates how to run foo"
62+
}
63+
],
64+
"name": "foo",
65+
"kind": "function",
66+
"members": {
67+
"instance": [],
68+
"static": []
69+
},
70+
"path": [
71+
"foo"
72+
]
73+
}
74+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# foo
2+
3+
This function returns the number one.
4+
5+
**Examples**
6+
7+
_demonstrates how to run foo_
8+
9+
```javascript
10+
foo(1);
11+
```
12+
13+
Returns **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"type": "root",
3+
"children": [
4+
{
5+
"depth": 1,
6+
"type": "heading",
7+
"children": [
8+
{
9+
"type": "text",
10+
"value": "foo"
11+
}
12+
]
13+
},
14+
{
15+
"type": "paragraph",
16+
"children": [
17+
{
18+
"type": "text",
19+
"value": "This function returns the number one.",
20+
"position": {
21+
"start": {
22+
"line": 1,
23+
"column": 1
24+
},
25+
"end": {
26+
"line": 1,
27+
"column": 38
28+
},
29+
"indent": []
30+
}
31+
}
32+
],
33+
"position": {
34+
"start": {
35+
"line": 1,
36+
"column": 1
37+
},
38+
"end": {
39+
"line": 1,
40+
"column": 38
41+
},
42+
"indent": []
43+
}
44+
},
45+
{
46+
"type": "strong",
47+
"children": [
48+
{
49+
"type": "text",
50+
"value": "Examples"
51+
}
52+
]
53+
},
54+
{
55+
"type": "paragraph",
56+
"children": [
57+
{
58+
"type": "emphasis",
59+
"children": [
60+
{
61+
"type": "text",
62+
"value": "demonstrates how to run foo"
63+
}
64+
]
65+
}
66+
]
67+
},
68+
{
69+
"lang": "javascript",
70+
"type": "code",
71+
"value": "foo(1);"
72+
},
73+
{
74+
"type": "paragraph",
75+
"children": [
76+
{
77+
"type": "text",
78+
"value": "Returns "
79+
},
80+
{
81+
"type": "strong",
82+
"children": [
83+
{
84+
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
85+
"type": "link",
86+
"children": [
87+
{
88+
"type": "text",
89+
"value": "Number"
90+
}
91+
]
92+
}
93+
]
94+
},
95+
{
96+
"type": "text",
97+
"value": " "
98+
},
99+
{
100+
"type": "paragraph",
101+
"children": [
102+
{
103+
"type": "text",
104+
"value": "numberone",
105+
"position": {
106+
"start": {
107+
"line": 1,
108+
"column": 1
109+
},
110+
"end": {
111+
"line": 1,
112+
"column": 10
113+
},
114+
"indent": []
115+
}
116+
}
117+
],
118+
"position": {
119+
"start": {
120+
"line": 1,
121+
"column": 1
122+
},
123+
"end": {
124+
"line": 1,
125+
"column": 10
126+
},
127+
"indent": []
128+
}
129+
}
130+
]
131+
}
132+
]
133+
}

0 commit comments

Comments
 (0)