@@ -14,8 +14,8 @@ test('should be parse comment', t => {
14
14
} ) ;
15
15
16
16
test ( 'should be parse CDATA' , t => {
17
- const tree = parser ( '<script><![CDATA[console.log(1);]]></script>' , { xmlMode : true } ) ;
18
- const expected = [ { tag : 'script' , content : [ 'console.log(1);' ] } ] ;
17
+ const tree = parser ( '<script><![CDATA[console.log(1);]]></script>' , { xmlMode : true } ) ;
18
+ const expected = [ { tag : 'script' , content : [ 'console.log(1);' ] } ] ;
19
19
t . deepEqual ( tree , expected ) ;
20
20
} ) ;
21
21
@@ -52,7 +52,7 @@ test.skip('should be parse tag with object in attribute data witchout escape', t
52
52
} ) ;
53
53
54
54
test . skip ( 'should be parse tag with object in attribute data escape' , t => {
55
- const json = JSON . stringify ( { button : { checkedView : 'extra' } } ) ;
55
+ const json = JSON . stringify ( { button : { checkedView : 'extra' } } ) ;
56
56
const html = '<button data-bem="' + json + '"' +
57
57
' type="submit"></button>' ;
58
58
const tree = parser ( html ) ;
@@ -70,25 +70,25 @@ test.skip('should be parse tag with object in attribute data escape', t => {
70
70
71
71
test ( 'should be parse isolated comment' , t => {
72
72
const tree = parser ( '<div><!--comment--></div>' ) ;
73
- const expected = [ { tag : 'div' , content : [ '<!--comment-->' ] } ] ;
73
+ const expected = [ { tag : 'div' , content : [ '<!--comment-->' ] } ] ;
74
74
t . deepEqual ( tree , expected ) ;
75
75
} ) ;
76
76
77
77
test ( 'should be parse comment before text content' , t => {
78
78
const tree = parser ( '<div><!--comment-->Text after comment</div>' ) ;
79
- const expected = [ { tag : 'div' , content : [ '<!--comment-->' , 'Text after comment' ] } ] ;
79
+ const expected = [ { tag : 'div' , content : [ '<!--comment-->' , 'Text after comment' ] } ] ;
80
80
t . deepEqual ( tree , expected ) ;
81
81
} ) ;
82
82
83
83
test ( 'should be parse comment after text content' , t => {
84
84
const tree = parser ( '<div>Text before comment.<!--comment--></div>' ) ;
85
- const expected = [ { tag : 'div' , content : [ 'Text before comment.' , '<!--comment-->' ] } ] ;
85
+ const expected = [ { tag : 'div' , content : [ 'Text before comment.' , '<!--comment-->' ] } ] ;
86
86
t . deepEqual ( tree , expected ) ;
87
87
} ) ;
88
88
89
89
test ( 'should be parse comment in the middle of text content' , t => {
90
90
const tree = parser ( '<div>Text surrounding <!--comment--> a comment.</div>' ) ;
91
- const expected = [ { tag : 'div' , content : [ 'Text surrounding ' , '<!--comment-->' , ' a comment.' ] } ] ;
91
+ const expected = [ { tag : 'div' , content : [ 'Text surrounding ' , '<!--comment-->' , ' a comment.' ] } ] ;
92
92
t . deepEqual ( tree , expected ) ;
93
93
} ) ;
94
94
@@ -101,7 +101,7 @@ test('should be parse doctype', t => {
101
101
test ( 'should be parse directive' , t => {
102
102
const options = {
103
103
directives : [
104
- { name : '?php' , start : '<' , end : '>' }
104
+ { name : '?php' , start : '<' , end : '>' }
105
105
]
106
106
} ;
107
107
const tree = parser ( '<?php echo "Hello word"; ?>' , options ) ;
@@ -112,7 +112,7 @@ test('should be parse directive', t => {
112
112
test ( 'should be parse regular expression directive' , t => {
113
113
const options = {
114
114
directives : [
115
- { name : / \? ( p h p | = ) .* / , start : '<' , end : '>' }
115
+ { name : / \? ( p h p | = ) .* / , start : '<' , end : '>' }
116
116
]
117
117
} ;
118
118
const tree1 = parser ( '<?php echo "Hello word"; ?>' , options ) ;
@@ -127,8 +127,8 @@ test('should be parse regular expression directive', t => {
127
127
test ( 'should be parse directives and tag' , t => {
128
128
const options = {
129
129
directives : [
130
- { name : '!doctype' , start : '<' , end : '>' } ,
131
- { name : '?php' , start : '<' , end : '>' }
130
+ { name : '!doctype' , start : '<' , end : '>' } ,
131
+ { name : '?php' , start : '<' , end : '>' }
132
132
]
133
133
} ;
134
134
const html = '<!doctype html><header><?php echo "Hello word"; ?></header><body>{{%njk test %}}</body>' ;
@@ -149,20 +149,20 @@ test('should be parse directives and tag', t => {
149
149
150
150
test ( 'should be parse tag' , t => {
151
151
const tree = parser ( '<html></html>' ) ;
152
- const expected = [ { tag : 'html' } ] ;
152
+ const expected = [ { tag : 'html' } ] ;
153
153
t . deepEqual ( tree , expected ) ;
154
154
} ) ;
155
155
156
156
test ( 'should be parse doctype and tag' , t => {
157
157
const tree = parser ( '<!doctype html><html></html>' ) ;
158
- const expected = [ '<!doctype html>' , { tag : 'html' } ] ;
158
+ const expected = [ '<!doctype html>' , { tag : 'html' } ] ;
159
159
t . deepEqual ( tree , expected ) ;
160
160
} ) ;
161
161
162
162
test ( 'should be parse tag attrs' , t => {
163
163
const tree = parser ( '<div id="id" class="class"></div>' ) ;
164
164
const expected = [ {
165
- tag : 'div' , attrs : { id : 'id' , class : 'class' }
165
+ tag : 'div' , attrs : { id : 'id' , class : 'class' }
166
166
} ] ;
167
167
t . deepEqual ( tree , expected ) ;
168
168
} ) ;
@@ -175,30 +175,30 @@ test('should be parse text', t => {
175
175
176
176
test ( 'should be parse text in content' , t => {
177
177
const tree = parser ( '<div>Text</div>' ) ;
178
- const expected = [ { tag : 'div' , content : [ 'Text' ] } ] ;
178
+ const expected = [ { tag : 'div' , content : [ 'Text' ] } ] ;
179
179
t . deepEqual ( tree , expected ) ;
180
180
} ) ;
181
181
182
182
test ( 'should be parse not a single node in tree' , t => {
183
183
const tree = parser ( '<span>Text1</span><span>Text2</span>Text3' ) ;
184
184
const expected = [
185
- { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3'
185
+ { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3'
186
186
] ;
187
187
t . deepEqual ( tree , expected ) ;
188
188
} ) ;
189
189
190
190
test ( 'should be parse not a single node in parent content' , t => {
191
191
const tree = parser ( '<div><span>Text1</span><span>Text2</span>Text3</div>' ) ;
192
192
const expected = [
193
- { tag : 'div' , content : [ { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3' ] }
193
+ { tag : 'div' , content : [ { tag : 'span' , content : [ 'Text1' ] } , { tag : 'span' , content : [ 'Text2' ] } , 'Text3' ] }
194
194
] ;
195
195
t . deepEqual ( tree , expected ) ;
196
196
} ) ;
197
197
198
198
test ( 'should be parse camelCase tag name' , t => {
199
199
const tree = parser ( '<mySuperTag></mySuperTag>' ) ;
200
200
const expected = [
201
- { tag : 'mySuperTag' }
201
+ { tag : 'mySuperTag' }
202
202
] ;
203
203
t . deepEqual ( tree , expected ) ;
204
204
} ) ;
@@ -207,7 +207,7 @@ test('should be parse simple contents are split with "<" in comment', t => {
207
207
const html = '<a> /* width < 800px */ <hr /> test</a>' ;
208
208
const tree = parser ( html ) ;
209
209
const expected = [
210
- { tag : 'a' , content : [ ' /* width < 800px */ ' , { tag : 'hr' } , ' test' ] }
210
+ { tag : 'a' , content : [ ' /* width < 800px */ ' , { tag : 'hr' } , ' test' ] }
211
211
] ;
212
212
t . deepEqual ( tree , expected ) ;
213
213
} ) ;
@@ -216,7 +216,7 @@ test('should be parse style contents are split with "<" in comment', t => {
216
216
const html = '<style> /* width < 800px */ @media (max-width: 800px) { /* selectors */} </style>' ;
217
217
const tree = parser ( html ) ;
218
218
const expected = [
219
- { tag : 'style' , content : [ ' /* width < 800px */ @media (max-width: 800px) { /* selectors */} ' ] }
219
+ { tag : 'style' , content : [ ' /* width < 800px */ @media (max-width: 800px) { /* selectors */} ' ] }
220
220
] ;
221
221
t . deepEqual ( tree , expected ) ;
222
222
} ) ;
@@ -229,7 +229,8 @@ test('should be parse script contents are split with "<" in comment', t => {
229
229
tag : 'script' ,
230
230
content : [
231
231
' var str = \'hey <form\'; if (!str.match(new RegExp(\'<(form|iframe)\', \'g\'))) { /* ... */ }'
232
- ] }
232
+ ]
233
+ }
233
234
] ;
234
235
t . deepEqual ( tree , expected ) ;
235
236
} ) ;
@@ -243,7 +244,7 @@ test('should be not converting html entity name', t => {
243
244
244
245
test ( 'should parse with source locations' , t => {
245
246
const html = '<h1>Test</h1>\n<p><b>Foo</b></p>' ;
246
- const tree = parser ( html , { sourceLocations : true } ) ;
247
+ const tree = parser ( html , { sourceLocations : true } ) ;
247
248
const expected = [
248
249
{
249
250
tag : 'h1' ,
@@ -312,6 +313,6 @@ test.only('should parse with input in button', t => {
312
313
]
313
314
}
314
315
] ;
315
- console . log ( { tree} ) ;
316
+ console . log ( { tree } ) ;
316
317
t . deepEqual ( tree , expected ) ;
317
318
} ) ;
0 commit comments