@@ -9,32 +9,38 @@ import path from "path";
9
9
describe ( "HTMLProcessor-test" , function ( ) {
10
10
describe ( "#parse" , function ( ) {
11
11
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>` ) ;
13
13
assert ( result . type === "Document" ) ;
14
14
} ) ;
15
15
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 ] ;
18
18
script . children . forEach ( code => {
19
19
assert . equal ( code . type , "CodeBlock" ) ;
20
20
} ) ;
21
21
} ) ;
22
22
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 ] ;
25
25
assert . equal ( pTag . type , "Paragraph" ) ;
26
26
} ) ;
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
+
27
33
it ( "should map type to TxtNode's type" , function ( ) {
28
34
function createTag ( tagName ) {
29
35
return `<${ tagName } ></${ tagName } >` ;
30
36
}
31
37
32
38
function testMap ( typeMap ) {
33
39
Object . keys ( typeMap ) . forEach ( tagName => {
34
- let result = parse ( createTag ( tagName ) ) ;
40
+ const result = parse ( createTag ( tagName ) ) ;
35
41
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 ] ;
38
44
assert . equal ( firstChild . type , expectedType ) ;
39
45
} ) ;
40
46
}
@@ -47,16 +53,19 @@ describe("HTMLProcessor-test", function () {
47
53
context ( "when target file is a HTML" , function ( ) {
48
54
beforeEach ( function ( ) {
49
55
textlint = new TextLintCore ( ) ;
50
- textlint . addProcessor ( HTMLProcessor ) ;
56
+ textlint . setupProcessors ( {
57
+ HTMLProcessor : HTMLProcessor
58
+ } ) ;
51
59
textlint . setupRules ( {
52
60
"no-todo" : require ( "textlint-rule-no-todo" )
53
61
} ) ;
54
62
} ) ;
55
63
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
+ } ) ;
60
69
} ) ;
61
70
} ) ;
62
71
} ) ;
0 commit comments