Skip to content

Commit ad32311

Browse files
author
alanclarke
committed
add encodeHtmlEntities option test for element attributes
1 parent 4ad917f commit ad32311

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

test/fixtures/serializer_test.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ exports['Regression - new line in <pre> tag'] = function () {
7070
};
7171

7272
exports['Regression - escapeEntities option'] = function () {
73-
var testCases = [
73+
var testHtmlCases = [
7474
{
7575
options: { encodeHtmlEntities: true },
7676
src: '<!DOCTYPE html><html><head></head><body>&</body></html>',
@@ -85,7 +85,30 @@ exports['Regression - escapeEntities option'] = function () {
8585
],
8686
parser = new Parser();
8787

88-
testCases.forEach(function (testCase) {
88+
testHtmlCases.forEach(function (testCase) {
89+
var serializer = new Serializer(null, testCase.options);
90+
var document = parser.parse(testCase.src),
91+
serializedResult = serializer.serialize(document);
92+
93+
assert.strictEqual(serializedResult, testCase.expected);
94+
});
95+
96+
var testAttributeCases = [
97+
{
98+
options: { encodeHtmlEntities: true },
99+
src: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>',
100+
expected: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&amp;world=2"></a></body></html>'
101+
},
102+
103+
{
104+
options: { encodeHtmlEntities: false },
105+
src: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>',
106+
expected: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>'
107+
}
108+
],
109+
parser = new Parser();
110+
111+
testAttributeCases.forEach(function (testCase) {
89112
var serializer = new Serializer(null, testCase.options);
90113
var document = parser.parse(testCase.src),
91114
serializedResult = serializer.serialize(document);

0 commit comments

Comments
 (0)