Permalink
Browse files

removed some extra vars and fixed jslint errors

  • Loading branch information...
1 parent 598e09e commit 724c295dc6d21ac31c5658013c3a379ab8b384af Matthew Mueller committed Jun 19, 2012
Showing with 94 additions and 119 deletions.
  1. +21 −23 test/api.manipulation.js
  2. +6 −7 test/api.traversing.js
  3. +2 −3 test/api.utils.js
  4. +16 −17 test/cheerio.js
  5. +7 −11 test/fixtures.js
  6. +1 −2 test/mocha.opts
  7. +36 −35 test/parse.js
  8. +5 −21 test/render.js
View
@@ -1,8 +1,6 @@
-var expect = require('expect.js');
-
-var $ = require('../');
-var fruits = require('./fixtures').fruits;
-
+var expect = require('expect.js'),
+ $ = require('../'),
+ fruits = require('./fixtures').fruits;
describe('$(...)', function() {
@@ -15,23 +13,23 @@ describe('$(...)', function() {
it('(html) : should add element as last child', function() {
var $fruits = $(fruits);
$('#fruits', $fruits).append('<li class="plum">Plum</li>');
- expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok;
+ expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok();
});
it('($(...)) : should add element as last child', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
$('#fruits', $fruits).append($plum);
- expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok;
+ expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok();
});
it('($(...), html) : should add multiple elements as last children', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
var grape = '<li class="grape">Grape</li>';
$('#fruits', $fruits).append($plum, grape);
- expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok;
- expect($('#fruits', $fruits).children(4).hasClass('grape')).to.be.ok;
+ expect($('#fruits', $fruits).children(3).hasClass('plum')).to.be.ok();
+ expect($('#fruits', $fruits).children(4).hasClass('grape')).to.be.ok();
});
it('(fn) : should add returned element as last child');
@@ -42,7 +40,7 @@ describe('$(...)', function() {
.children()
.children()
.parent();
- expect(obj).to.be.ok;
+ expect(obj).to.be.ok();
});
});
@@ -56,23 +54,23 @@ describe('$(...)', function() {
it('(html) : should add element as first child', function() {
var $fruits = $(fruits);
$('#fruits', $fruits).prepend('<li class="plum">Plum</li>');
- expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok;
+ expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok();
});
it('($(...)) : should add element as first child', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
$('#fruits', $fruits).prepend($plum);
- expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok;
+ expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok();
});
it('(html, $(...), html) : should add multiple elements as first children', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
var grape = '<li class="grape">Grape</li>';
$('#fruits', $fruits).prepend($plum, grape);
- expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok;
- expect($('#fruits', $fruits).children(1).hasClass('grape')).to.be.ok;
+ expect($('#fruits', $fruits).children(0).hasClass('plum')).to.be.ok();
+ expect($('#fruits', $fruits).children(1).hasClass('grape')).to.be.ok();
});
it('(fn) : should add returned element as first child');
@@ -89,23 +87,23 @@ describe('$(...)', function() {
var $fruits = $(fruits);
var grape = '<li class="grape">Grape</li>';
$('.apple', $fruits).after(grape);
- expect($('.apple', $fruits).next().hasClass('grape')).to.be.ok;
+ expect($('.apple', $fruits).next().hasClass('grape')).to.be.ok();
});
it('($(...)) : should add element as next sibling', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
$('.apple', $fruits).after($plum);
- expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok;
+ expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok();
});
it('($(...), html) : should add multiple elements as next siblings', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
var grape = '<li class="grape">Grape</li>';
$('.apple', $fruits).after($plum, grape);
- expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok;
- expect($('.plum', $fruits).next().hasClass('grape')).to.be.ok;
+ expect($('.apple', $fruits).next().hasClass('plum')).to.be.ok();
+ expect($('.plum', $fruits).next().hasClass('grape')).to.be.ok();
});
it('(fn) : should add returned element as next sibling');
@@ -122,23 +120,23 @@ describe('$(...)', function() {
var $fruits = $(fruits);
var grape = '<li class="grape">Grape</li>';
$('.apple', $fruits).before(grape);
- expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok;
+ expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok();
});
it('($(...)) : should add element as previous sibling', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
$('.apple', $fruits).before($plum);
- expect($('.apple', $fruits).prev().hasClass('plum')).to.be.ok;
+ expect($('.apple', $fruits).prev().hasClass('plum')).to.be.ok();
});
it('($(...), html) : should add multiple elements as previous siblings', function() {
var $fruits = $(fruits);
var $plum = $('<li class="plum">Plum</li>');
var grape = '<li class="grape">Grape</li>';
$('.apple', $fruits).before($plum, grape);
- expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok;
- expect($('.grape', $fruits).prev().hasClass('plum')).to.be.ok;
+ expect($('.apple', $fruits).prev().hasClass('grape')).to.be.ok();
+ expect($('.grape', $fruits).prev().hasClass('plum')).to.be.ok();
});
it('(fn) : should add returned element as previous sibling');
@@ -167,7 +165,7 @@ describe('$(...)', function() {
var $fruits = $(fruits);
var plum = $('<li class="plum">Plum</li>');
$('.pear', $fruits).replaceWith(plum);
- expect($('.orange', $fruits).next().hasClass('plum')).to.be.ok;
+ expect($('.orange', $fruits).next().hasClass('plum')).to.be.ok();
expect($('.orange', $fruits).next().html()).to.equal('Plum');
});
View
@@ -1,7 +1,6 @@
-var expect = require('expect.js');
-
-var $ = require('../');
-var fruits = require('./fixtures').fruits;
+var expect = require('expect.js'),
+ $ = require('../'),
+ fruits = require('./fixtures').fruits;
describe('$(...)', function() {
@@ -39,7 +38,7 @@ describe('$(...)', function() {
});
it('(selector) : should return children matching selector', function() {
- expect($('ul', fruits).children('.orange').hasClass('orange')).to.be.ok;
+ expect($('ul', fruits).children('.orange').hasClass('orange')).to.be.ok();
});
it('(invalid selector) : should return empty', function() {
@@ -53,7 +52,7 @@ describe('$(...)', function() {
describe('.next', function() {
it('() : should return next element', function() {
- expect($('.orange', fruits).next().hasClass('pear')).to.be.ok;
+ expect($('.orange', fruits).next().hasClass('pear')).to.be.ok();
});
it('(no next) : should return null (?)');
@@ -63,7 +62,7 @@ describe('$(...)', function() {
describe('.prev', function() {
it('() : should return previous element', function() {
- expect($('.orange', fruits).prev().hasClass('apple')).to.be.ok;
+ expect($('.orange', fruits).prev().hasClass('apple')).to.be.ok();
});
it('(no prev) : should return null (?)');
View
@@ -1,6 +1,5 @@
-var expect = require('expect.js');
-
-var $ = require('../');
+var expect = require('expect.js'),
+ $ = require('../');
describe('$', function() {
View
@@ -1,51 +1,50 @@
-var expect = require('expect.js');
-var _ = require('underscore');
+var expect = require('expect.js'),
+ _ = require('underscore'),
+ $ = require('../'),
+ fruits = require('./fixtures').fruits;
-var $ = require('../');
-var fruits = require('./fixtures').fruits;
-
-
-var script = '<script src="script.js" type="text/javascript"></script>';
-var multiclass = '<p><a class="btn primary" href="#">Save</a></p>';
+// HTML
+var script = '<script src="script.js" type="text/javascript"></script>',
+ multiclass = '<p><a class="btn primary" href="#">Save</a></p>';
describe('cheerio', function() {
it('should get the version', function() {
- expect(/\d\.\d\.\d/.test($.version)).to.be.ok;
+ expect(/\d\.\d\.\d/.test($.version)).to.be.ok();
});
it('$(null) should return be empty', function() {
- expect($(null)).to.be.empty;
+ expect($(null)).to.be.empty();
});
it('$(undefined) should be empty', function() {
- expect($(undefined)).to.be.empty;
+ expect($(undefined)).to.be.empty();
});
it('$(null) should be empty', function() {
- expect($('')).to.be.empty;
+ expect($('')).to.be.empty();
});
it('$(selector) with no context or root should be empty', function() {
- expect($('.h2')).to.be.empty;
- expect($('#fruits')).to.be.empty;
+ expect($('.h2')).to.be.empty();
+ expect($('#fruits')).to.be.empty();
});
it('should be able to create html without a root or context', function() {
var $h2 = $('<h2>');
- expect($h2).to.not.be.empty;
+ expect($h2).to.not.be.empty();
expect($h2).to.have.length(1);
expect($h2[0].name).to.equal('h2');
});
it('should be able to create complicated html', function() {
var $script = $(script);
- expect($script).to.not.be.empty;
+ expect($script).to.not.be.empty();
expect($script).to.have.length(1);
expect($script[0].attribs.src).to.equal('script.js');
expect($script[0].attribs.type).to.equal('text/javascript');
- expect($script[0].children).to.be.empty;
+ expect($script[0].children).to.be.empty();
});
var testAppleSelect = function($apple) {
View
@@ -1,11 +1,7 @@
-module.exports = {
-
- fruits: [
- '<ul id="fruits">',
- '<li class="apple">Apple</li>',
- '<li class="orange">Orange</li>',
- '<li class="pear">Pear</li>',
- '</ul>'
- ].join('')
-
-};
+exports.fruits = [
+ '<ul id="fruits">',
+ '<li class="apple">Apple</li>',
+ '<li class="orange">Orange</li>',
+ '<li class="pear">Pear</li>',
+ '</ul>'
+].join('');
View
@@ -1,3 +1,2 @@
--reporter list
---growl
---compilers coffee:coffee-script
+--growl
Oops, something went wrong.

2 comments on commit 724c295

Contributor

davidchambers replied Jun 19, 2012

I was going to look at exactly what expect(expression).to.be.ok does. It certainly looks as though it should be a method call (and Vim kept telling me so), but I wondered whether it's a magical "getter". In the end I just trusted the CoffeeScript tests, but it turns out we were never actually invoking the ok method. >.<

Ohhh right good catch on options, I tend to go with options = options || {}.. let me fix that now.

And yah, haha, I noticed that after the 2nd pass - that was my fault when I swapped out should.js for expect.js :-[

Please sign in to comment.