Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Unified Diff: tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/render.js

Issue 125733002: Add vulcanize to tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/render.js
diff --git a/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/render.js b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/render.js
new file mode 100644
index 0000000000000000000000000000000000000000..140d8f8c1d8b72797290b51bb0f146a1e6738677
--- /dev/null
+++ b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/render.js
@@ -0,0 +1,62 @@
+var expect = require('expect.js'),
+ parse = require('../lib/parse'),
+ render = require('../lib/render');
+
+var html = function(str, options) {
+ options = options || {};
+ var dom = parse(str, options);
+ return render(dom);
+};
+
+describe('render', function() {
+
+ describe('(html)', function() {
+
+ it('should render <br /> tags correctly', function() {
+ var str = '<br />';
+ expect(html(str)).to.equal('<br>');
+ });
+
+ it('should handle double quotes within single quoted attributes properly', function() {
+ var str = "<hr class='an \"edge\" case' />";
+ expect(html(str)).to.equal('<hr class="an &quot;edge&quot; case">');
+ });
+
+ it('should retain encoded HTML content within attributes', function() {
+ var str = '<hr class="cheerio &amp; node = happy parsing" />';
+ expect(html(str)).to.equal('<hr class="cheerio &amp; node = happy parsing">');
+ });
+
+ it('should shorten the "checked" attribute when it contains the value "checked"', function() {
+ var str = '<input checked/>';
+ expect(html(str)).to.equal('<input checked>');
+ });
+
+ it('should not shorten the "name" attribute when it contains the value "name"', function() {
+ var str = '<input name="name"/>';
+ expect(html(str)).to.equal('<input name="name">');
+ });
+
+ it('should render comments correctly', function() {
+ var str = '<!-- comment -->';
+ expect(html(str)).to.equal('<!-- comment -->');
+ });
+
+ it('should render whitespace by default', function() {
+ var str = '<a href="./haha.html">hi</a> <a href="./blah.html">blah</a>';
+ expect(html(str)).to.equal(str);
+ });
+
+ it('should ignore whitespace if specified', function() {
+ var str = '<a href="./haha.html">hi</a> <a href="./blah.html">blah </a>';
+ expect(html(str, {ignoreWhitespace: true})).to.equal('<a href="./haha.html">hi</a><a href="./blah.html">blah </a>');
+ });
+
+ it('should preserve multiple hyphens in data attributes', function() {
+ var str = '<div data-foo-bar-baz="value"></div>';
+ expect(html(str)).to.equal('<div data-foo-bar-baz="value"></div>');
+ });
+
+ });
+
+});

Powered by Google App Engine
This is Rietveld 408576698