Skip to content

Commit

Permalink
test: add more test for parseAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
leizongmin committed Jul 27, 2020
1 parent 212883e commit 9cddd99
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/test_html_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ describe("test HTML parser", function() {

it("#parseTag & #parseAttr", function() {
var html = parseTag(
'hi:<a href="#"target=_blank title="this is a link">link</a>',
'hi:<a href="#"target=_blank title="this is a link" alt = hello class = "hello2">link</a>',
function(sourcePosition, position, tag, html, isClosing) {
if (tag === "a") {
if (isClosing) return "</a>";
var attrhtml = parseAttr(html.slice(2, -1), function(name, value) {
if (name === "href" || name === "target") {
if (name === "href" || name === "target" || name === "alt" || name === "class") {
return attr(name, value);
}
});
Expand All @@ -134,6 +134,6 @@ describe("test HTML parser", function() {
escapeHtml
);
debug(html);
assert.equal(html, 'hi:<a href="#" target="_blank">link</a>');
assert.equal(html, 'hi:<a href="#" target="_blank" alt="hello" class="hello2">link</a>');
});
});

0 comments on commit 9cddd99

Please sign in to comment.