39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
|
var expect = require('expect.js'),
|
||
|
cheerio = require('..'),
|
||
|
food = require('./fixtures').food;
|
||
|
|
||
|
describe('utility methods', function() {
|
||
|
|
||
|
describe('.contains', function() {
|
||
|
|
||
|
var $;
|
||
|
|
||
|
beforeEach(function() {
|
||
|
$ = cheerio.load(food);
|
||
|
});
|
||
|
|
||
|
it('(container, contained) : should correctly detect the provided element', function() {
|
||
|
var $food = $('#food');
|
||
|
var $fruits = $('#fruits');
|
||
|
var $apple = $('.apple');
|
||
|
|
||
|
expect($.contains($food[0], $fruits[0])).to.equal(true);
|
||
|
expect($.contains($food[0], $apple[0])).to.equal(true);
|
||
|
});
|
||
|
|
||
|
it('(container, other) : should not detect elements that are not contained', function() {
|
||
|
var $fruits = $('#fruits');
|
||
|
var $vegetables = $('#vegetables');
|
||
|
var $apple = $('.apple');
|
||
|
|
||
|
expect($.contains($vegetables[0], $apple[0])).to.equal(false);
|
||
|
expect($.contains($fruits[0], $vegetables[0])).to.equal(false);
|
||
|
expect($.contains($vegetables[0], $fruits[0])).to.equal(false);
|
||
|
expect($.contains($fruits[0], $fruits[0])).to.equal(false);
|
||
|
expect($.contains($vegetables[0], $vegetables[0])).to.equal(false);
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
});
|