Skip to content

Commit 0ba0085

Browse files
committed
Add failing unit test
1 parent 9a695f2 commit 0ba0085

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const {createPackageDoc} = require("@webdoc/model");
2+
const {parse} = require("../lib/parse");
3+
4+
const expect = require("chai").expect;
5+
6+
describe("@webdoc/parser.parser", function() {
7+
it("should infer access, default value, and type for fields", function() {
8+
const docs = parse([{
9+
content: `
10+
/** Example class */
11+
class Example {
12+
/**
13+
* Field description
14+
*/
15+
protected field: boolean = true;
16+
}
17+
`,
18+
path: ".ts",
19+
package: createPackageDoc(),
20+
}]);
21+
22+
expect(docs.members.length).to.equal(1);
23+
expect(docs.members[0].members.length).to.equal(1);
24+
25+
const fieldDoc = docs.members[0].members[0];
26+
27+
expect(fieldDoc.access).to.equal("protected");
28+
expect(fieldDoc.dataType && fieldDoc.dataType[0]).to.equal("boolean");
29+
expect(fieldDoc.defaultValue).to.equal("true");
30+
expect(fieldDoc.description).to.equal("Field description");
31+
});
32+
});

0 commit comments

Comments
 (0)