diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-04 18:41:12 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-04 18:41:12 +0000 |
| commit | b2ccfa5cc2cd4d7f8f80f0555e2586387375a98e (patch) | |
| tree | e4ce2260bf93a03865400adb4c389720140cf3d1 /tests/html-writer.tests.js | |
| parent | 774ff6722f9df9fec9f350288023aa500f49df61 (diff) | |
Move writers into a separate directory
Diffstat (limited to 'tests/html-writer.tests.js')
| -rw-r--r-- | tests/html-writer.tests.js | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/tests/html-writer.tests.js b/tests/html-writer.tests.js deleted file mode 100644 index 64c9ea0..0000000 --- a/tests/html-writer.tests.js +++ /dev/null @@ -1,106 +0,0 @@ -var assert = require("assert"); -var test = require("./testing").test; - -var htmlWriter = require("../lib/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>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>"); - }); - - 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>"); - }); -}); |
