Skip to content

Commit 5655c89

Browse files
committed
1 parent 8d4e1ac commit 5655c89

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/mapping.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const nodeTypes = {
2424
"Bullet": "Bullet", // no need?
2525
"heading": "Header",
2626
"code": "CodeBlock",
27+
"comment": "Comment",
2728
"HtmlBlock": "Html",
2829
"ReferenceDef": "ReferenceDef",
2930
"horizontalRule": "HorizontalRule",

test/HTMLProcessor-test.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,38 @@ import path from "path";
99
describe("HTMLProcessor-test", function () {
1010
describe("#parse", function () {
1111
it("should return AST", function () {
12-
var result = parse(`<div><p><span>aaaa</span></p></div>`);
12+
const result = parse(`<div><p><span>aaaa</span></p></div>`);
1313
assert(result.type === "Document");
1414
});
1515
it("script should CodeBlock", function () {
16-
var result = parse(`<script> var a = 1; </script>`);
17-
let script = result.children[0];
16+
const result = parse(`<script> const a = 1; </script>`);
17+
const script = result.children[0];
1818
script.children.forEach(code => {
1919
assert.equal(code.type, "CodeBlock");
2020
});
2121
});
2222
it("<p> should Paragraph", function () {
23-
var result = parse(`<p>test</p>`);
24-
let pTag = result.children[0];
23+
const result = parse(`<p>test</p>`);
24+
const pTag = result.children[0];
2525
assert.equal(pTag.type, "Paragraph");
2626
});
27+
it("<!-- comment --> should be Comment", function () {
28+
const result = parse(`<!-- comment -->`);
29+
const commentNode = result.children[0];
30+
assert.equal(commentNode.type, "Comment");
31+
});
32+
2733
it("should map type to TxtNode's type", function () {
2834
function createTag(tagName) {
2935
return `<${tagName}></${tagName}>`;
3036
}
3137

3238
function testMap(typeMap) {
3339
Object.keys(typeMap).forEach(tagName => {
34-
let result = parse(createTag(tagName));
40+
const result = parse(createTag(tagName));
3541
assert(result.type === "Document");
36-
let firstChild = result.children[0];
37-
let expectedType = typeMap[tagName];
42+
const firstChild = result.children[0];
43+
const expectedType = typeMap[tagName];
3844
assert.equal(firstChild.type, expectedType);
3945
});
4046
}
@@ -47,16 +53,19 @@ describe("HTMLProcessor-test", function () {
4753
context("when target file is a HTML", function () {
4854
beforeEach(function () {
4955
textlint = new TextLintCore();
50-
textlint.addProcessor(HTMLProcessor);
56+
textlint.setupProcessors({
57+
HTMLProcessor: HTMLProcessor
58+
});
5159
textlint.setupRules({
5260
"no-todo": require("textlint-rule-no-todo")
5361
});
5462
});
5563
it("should report error", function () {
56-
var fixturePath = path.join(__dirname, "/fixtures/test.html");
57-
let results = textlint.lintFile(fixturePath);
58-
assert(results.messages.length > 0);
59-
assert(results.filePath === fixturePath);
64+
const fixturePath = path.join(__dirname, "/fixtures/test.html");
65+
return textlint.lintFile(fixturePath).then(results => {
66+
assert(results.messages.length > 0);
67+
assert(results.filePath === fixturePath);
68+
});
6069
});
6170
});
6271
});

0 commit comments

Comments
 (0)