Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(jqLiteSpec): jQuery's css() getter works only for valid rules
Browse files Browse the repository at this point in the history
foo.css('bogus', 'value')
foo.css('bogus') => null

so I had to change all tests to use valid css rules
  • Loading branch information
IgorMinar committed Sep 16, 2011
1 parent 0d7fe97 commit ab407de
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,34 +288,35 @@ describe('jqLite', function(){
it('should set and read css', function(){
var selector = jqLite([a, b]);

expect(selector.css('prop', 'value')).toEqual(selector);
expect(jqLite(a).css('prop')).toEqual('value');
expect(jqLite(b).css('prop')).toEqual('value');
expect(selector.css('margin', '1px')).toEqual(selector);
expect(jqLite(a).css('margin')).toEqual('1px');
expect(jqLite(b).css('margin')).toEqual('1px');

expect(selector.css({'prop': 'new value'})).toEqual(selector);
expect(jqLite(a).css('prop')).toEqual('new value');
expect(jqLite(b).css('prop')).toEqual('new value');
expect(selector.css({'margin': '2px'})).toEqual(selector);
expect(jqLite(a).css('margin')).toEqual('2px');
expect(jqLite(b).css('margin')).toEqual('2px');

jqLite(b).css({'prop': 'new value 2'});
expect(jqLite(selector).css('prop')).toEqual('new value');
expect(jqLite(b).css('prop')).toEqual('new value 2');
jqLite(b).css({'margin': '3px'});
expect(jqLite(selector).css('margin')).toEqual('2px');
expect(jqLite(a).css('margin')).toEqual('2px');
expect(jqLite(b).css('margin')).toEqual('3px');

selector.css('prop', null);
expect(jqLite(a).css('prop')).toBeFalsy();
expect(jqLite(b).css('prop')).toBeFalsy();
selector.css('margin', '');
expect(jqLite(a).css('margin')).toBeFalsy();
expect(jqLite(b).css('margin')).toBeFalsy();
});


it('should set a bunch of css properties specified via an object', function() {
expect(jqLite(a).css('foo')).toBeFalsy();
expect(jqLite(a).css('bar')).toBeFalsy();
expect(jqLite(a).css('baz')).toBeFalsy();
expect(jqLite(a).css('margin')).toBeFalsy();
expect(jqLite(a).css('padding')).toBeFalsy();
expect(jqLite(a).css('border')).toBeFalsy();

jqLite(a).css({'foo': 'a', 'bar': 'b', 'baz': ''});
jqLite(a).css({'margin': '1px', 'padding': '2px', 'border': ''});

expect(jqLite(a).css('foo')).toBe('a');
expect(jqLite(a).css('bar')).toBe('b');
expect(jqLite(a).css('baz')).toBeFalsy();
expect(jqLite(a).css('margin')).toBe('1px');
expect(jqLite(a).css('padding')).toBe('2px');
expect(jqLite(a).css('border')).toBeFalsy();
});
});

Expand Down

0 comments on commit ab407de

Please sign in to comment.