Skip to content

Commit bc75efb

Browse files
author
Ian Warren
committed
Add failing test for setting attr to undefined
1 parent f8c5497 commit bc75efb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/api.attributes.js

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ describe('$(...)', function() {
3838
expect($pear).to.be.a($);
3939
});
4040

41+
it('(chaining) setting value and calling attr returns result', function() {
42+
var pearAttr = $('.pear').attr('foo', 'bar').attr('foo');
43+
expect(pearAttr).to.equal('bar');
44+
});
45+
46+
it('(chaining) setting attr to null returns a $', function() {
47+
var $pear = $('.pear').attr('foo', null);
48+
expect($pear).to.be.a($);
49+
});
50+
51+
it('(chaining) setting attr to undefined returns a $', function() {
52+
var $pear = $('.pear').attr('foo', undefined);
53+
expect($('#pear')).to.have.length(1);
54+
expect($('#pear').attr('foo')).to.be(undefined);
55+
expect($pear).to.be.a($);
56+
});
57+
4158
it('(key, value) : should set attr', function() {
4259
var $el = cheerio('<div></div> <div></div>').attr('class', 'pear');
4360

0 commit comments

Comments
 (0)