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

Unified Diff: tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/api.css.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/api.css.js
diff --git a/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/api.css.js b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/api.css.js
new file mode 100644
index 0000000000000000000000000000000000000000..564d95a12553dbcb9887ed787743747c6607801c
--- /dev/null
+++ b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/test/api.css.js
@@ -0,0 +1,73 @@
+var expect = require('expect.js');
+var $ = require('..');
+
+describe('$(...)', function() {
+
+ describe('.css', function() {
+ it('(prop): should return a css property value', function() {
+ var el = $('<li style="hai: there">');
+ expect(el.css('hai')).to.equal('there');
+ });
+
+ it('([prop1, prop2]): should return the specified property values as an object', function() {
+ var el = $('<li style="margin: 1px; padding: 2px; color: blue;">');
+ expect(el.css(['margin', 'color'])).to.eql({ margin: '1px', color: 'blue' });
+ });
+
+ it('(prop, val): should set a css property', function() {
+ var el = $('<li style="margin: 0;"></li><li></li>');
+ el.css('color', 'red');
+ expect(el.attr('style')).to.equal('margin: 0; color: red;');
+ expect(el.eq(1).attr('style')).to.equal('color: red;');
+ });
+
+ it('(prop, ""): should unset a css property', function() {
+ var el = $('<li style="padding: 1px; margin: 0;">');
+ el.css('padding', '');
+ expect(el.attr('style')).to.equal('margin: 0;');
+ });
+
+ describe('(prop, function):', function() {
+ beforeEach(function() {
+ this.$el = $('<div style="margin: 0;"></div><div style="margin: 0;"></div><div style="margin: 0;">');
+ });
+
+ it('should iterate over the selection', function() {
+ var count = 0;
+ var $el = this.$el;
+ this.$el.css('margin', function(idx, elem) {
+ expect(idx).to.equal(count);
+ expect(elem).to.equal($el[count]);
+ expect(this).to.equal($el[count]);
+ count++;
+ });
+ expect(count).to.equal(3);
+ });
+
+ it('should set each attribute independently', function() {
+ var values = ['4px', '', undefined];
+ this.$el.css('margin', function(idx) {
+ return values[idx];
+ });
+ expect(this.$el.eq(0).attr('style')).to.equal('margin: 4px;');
+ expect(this.$el.eq(1).attr('style')).to.equal('');
+ expect(this.$el.eq(2).attr('style')).to.equal('margin: 0;');
+ });
+ });
+
+ it('(obj): should set each key and val', function() {
+ var el = $('<li style="padding: 0;"></li><li></li>');
+ el.css({ foo: 0 });
+ expect(el.eq(0).attr('style')).to.equal('padding: 0; foo: 0;');
+ expect(el.eq(1).attr('style')).to.equal('foo: 0;');
+ });
+
+ describe('parser', function(){
+ it('should allow any whitespace between declarations', function() {
+ var el = $('<li style="one \t:\n 0;\n two \f\r:\v 1">');
+ expect(el.css(['one', 'two'])).to.eql({ one: 0, two: 1 });
+ });
+ });
+ });
+
+});

Powered by Google App Engine
This is Rietveld 408576698