Skip to content

Commit 5ff79fe

Browse files
authored
Merge pull request #18 from Janpot/self-closing
Add test for self closing tags
2 parents f5ef394 + 44ec273 commit 5ff79fe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/parser.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,17 @@ describe('parser', () => {
202202
expect(Array.isArray(strictResult.items)).toBe(true);
203203
expect(strictResult.items.length).toBe(0);
204204
});
205+
206+
test('recognizes self-closing tags', () => {
207+
const html =
208+
'<div itemscope>' +
209+
' <span itemprop="price" content="139.90" />' +
210+
' foo' +
211+
' bar' +
212+
'</div>';
213+
const result = parser.toJson(html);
214+
expect(Array.isArray(result.items)).toBe(true);
215+
expect(result.items.length).toBe(1);
216+
expect(result.items[0].properties.price[0]).toBe('139.90');
217+
});
205218
});

0 commit comments

Comments
 (0)