Skip to content

Commit

Permalink
Added unit tests for is operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
arb committed May 5, 2013
1 parent 4aec5f6 commit 14eb828
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions test/api.attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe('$(...)', function() {
$apple.attr('href', 'http://github.com/"><script>alert("XSS!")</script><br');
expect($apple.html()).to.not.contain('<script>alert("XSS!")</script>');
});

it('(key, value) : should coerce values to a string', function() {
var $apple = $('.apple', fruits);
$apple.attr('data-test', 1);
expect($apple[0].attribs['data-test']).to.equal('1');
expect($apple.attr('data-test')).to.equal('1');
});
});
});

describe('.val', function() {
Expand Down Expand Up @@ -257,4 +257,28 @@ describe('$(...)', function() {

});

describe('.is', function () {
it('() should return false', function () {
expect($('li.apple', fruits).is()).to.be(false)
})
it('(true selector) should return true', function () {
expect($('#vegetables', vegetables).is('ul')).to.be(true)
})
it('(false selector) should return false', function () {
expect($('#vegetables', vegetables).is('div')).to.be(false)
})
it('(true predicate) should return true', function () {
var result = $('li', fruits).is(function() {
return this.hasClass('pear')
})
expect(result).to.be(true)
})
it('(false predicate) should return false', function () {
var result = $('li', fruits).last().is(function() {
return this.name === 'ul'
})
expect(result).to.be(false)
})
})

});

0 comments on commit 14eb828

Please sign in to comment.