diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-04-10 14:22:21 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-04-10 14:22:21 +0100 |
| commit | dee75b1261646edb99ae01a231036fd9c468fe83 (patch) | |
| tree | f340ce912a525fc5408da7da8c9997c863f8e501 /tests | |
| parent | 7e49d52fb9501a1bdd85d6c9d35d09d50aabb569 (diff) | |
Add basic indentation of HTML
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/html-writer.tests.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/html-writer.tests.js b/tests/html-writer.tests.js index 8a40afb..2a22caf 100644 --- a/tests/html-writer.tests.js +++ b/tests/html-writer.tests.js @@ -10,7 +10,7 @@ describe('html-writer', function() { writer.open("p"); writer.text("Hello"); writer.close("p"); - return assert.equal("<p>Hello</p>", writer.asString()); + return assert.equal(writer.asString(), "<p>Hello</p>"); }); test('can nest elements', function() { @@ -23,6 +23,31 @@ describe('html-writer', function() { writer.text("Two"); writer.close("li"); writer.close("ul"); - return assert.equal("<ul><li>One</li><li>Two</li></ul>", writer.asString()); + return assert.equal(writer.asString(), "<ul><li>One</li><li>Two</li></ul>"); + }); + + test('indents element if prettyPrint is true', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("ul"); + writer.open("li"); + writer.text("One"); + writer.close("li"); + writer.open("li"); + writer.text("Two"); + writer.close("li"); + writer.close("ul"); + return assert.equal(writer.asString(), "<ul>\n <li>One</li>\n <li>Two</li>\n</ul>"); + }); + + test('indents closing element correctly when nested inside another indented element', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("div"); + writer.open("div"); + writer.open("div"); + writer.text("Hello"); + writer.close("div"); + writer.close("div"); + writer.close("div"); + return assert.equal(writer.asString(), "<div>\n <div>\n <div>\n Hello\n </div>\n </div>\n</div>"); }); }) |
