diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-07-07 22:17:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-07-07 22:17:34 +0100 |
| commit | a080fc59a3fca08bdc6e23a2eeae440f5c7047b3 (patch) | |
| tree | 3d56033c294c617eb7de6b693750efb70a81dd4f /test/writers/html-writer.tests.js | |
| parent | 28a0e40b645c051d91626ca90959e847b061c8da (diff) | |
Use exports for all tests
Diffstat (limited to 'test/writers/html-writer.tests.js')
| -rw-r--r-- | test/writers/html-writer.tests.js | 220 |
1 files changed, 109 insertions, 111 deletions
diff --git a/test/writers/html-writer.tests.js b/test/writers/html-writer.tests.js index 41d8839..b5cdf4e 100644 --- a/test/writers/html-writer.tests.js +++ b/test/writers/html-writer.tests.js @@ -1,117 +1,115 @@ var assert = require("assert"); -var test = require("../testing").test; +var test = require("../test")(module); var htmlWriter = require("../../lib/writers/html-writer"); -describe('html-writer', function() { - test('can generate simple paragraph', function() { - var writer = htmlWriter.writer(); - writer.open("p"); - writer.text("Hello"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>Hello</p>"); - }); - - test('can nest elements', function() { - var writer = htmlWriter.writer(); - 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><li>One</li><li>Two</li></ul>"); - }); - - test('indents text if prettyPrint is true', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.text("One"); - writer.close("p"); - writer.open("p"); - writer.text("Two"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n One\n</p>\n<p>\n Two\n</p>"); - }); - - 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>\n One\n </li>\n <li>\n Two\n </li>\n</ul>"); - }); - - test('when prettyPrint is true inner elements do not have new lines', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.text("One"); - writer.open("em"); - writer.text("Two"); - writer.close("em"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n One<em>Two</em>\n</p>"); - }); - - 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>"); - }); - - test('newlines in text are indented', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.text("One\nTwo"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n One\n Two\n</p>"); - }); - - test('run of text has only one new line', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.text("One"); - writer.text("Two"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n OneTwo\n</p>"); - }); - - test('run of html has only one new line', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.append("One"); - writer.append("Two"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n OneTwo\n</p>"); - }); - - test('self closing elements are indented', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.selfClosing("br"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n <br />\n</p>"); - }); - - test('newlines in appended HTML are indented', function() { - var writer = htmlWriter.writer({prettyPrint: true}); - writer.open("p"); - writer.append("One\nTwo"); - writer.close("p"); - return assert.equal(writer.asString(), "<p>\n One\n Two\n</p>"); - }); +test('can generate simple paragraph', function() { + var writer = htmlWriter.writer(); + writer.open("p"); + writer.text("Hello"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>Hello</p>"); +}); + +test('can nest elements', function() { + var writer = htmlWriter.writer(); + 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><li>One</li><li>Two</li></ul>"); +}); + +test('indents text if prettyPrint is true', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.text("One"); + writer.close("p"); + writer.open("p"); + writer.text("Two"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n One\n</p>\n<p>\n Two\n</p>"); +}); + +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>\n One\n </li>\n <li>\n Two\n </li>\n</ul>"); +}); + +test('when prettyPrint is true inner elements do not have new lines', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.text("One"); + writer.open("em"); + writer.text("Two"); + writer.close("em"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n One<em>Two</em>\n</p>"); +}); + +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>"); +}); + +test('newlines in text are indented', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.text("One\nTwo"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n One\n Two\n</p>"); +}); + +test('run of text has only one new line', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.text("One"); + writer.text("Two"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n OneTwo\n</p>"); +}); + +test('run of html has only one new line', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.append("One"); + writer.append("Two"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n OneTwo\n</p>"); +}); + +test('self closing elements are indented', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.selfClosing("br"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n <br />\n</p>"); +}); + +test('newlines in appended HTML are indented', function() { + var writer = htmlWriter.writer({prettyPrint: true}); + writer.open("p"); + writer.append("One\nTwo"); + writer.close("p"); + return assert.equal(writer.asString(), "<p>\n One\n Two\n</p>"); }); |
