Skip to content
Browse files

Move tests for `contains` method

The `api.utils.js` test file hosts the tests for all other instance
methods; there is no need for a `utilities.js` file dedicated to a
single method.
  • Loading branch information...
1 parent 83c2e27 commit f228490e9d3cff5699868e94648b214904a40130 @jugglinmike jugglinmike committed Jun 30, 2014
Showing with 31 additions and 38 deletions.
  1. +31 −0 test/api.utils.js
  2. +0 −38 test/utilities.js
View
31 test/api.utils.js
@@ -154,6 +154,37 @@ describe('cheerio', function() {
});
+ describe('.contains', function() {
+
+ var $;
+
+ beforeEach(function() {
+ $ = cheerio.load(fixtures.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);
+ });
+
+ });
+
describe('.root', function() {
it('() : should return a cheerio-wrapped root object', function() {
View
38 test/utilities.js
@@ -1,38 +0,0 @@
-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);
- });
-
- });
-
-});

0 comments on commit f228490

Please sign in to comment.
Something went wrong with that request. Please try again.