Permalink
Browse files

Refactor tests using mocha and should.js

  • Loading branch information...
1 parent d01c83d commit 09f0446050a9165465a82ab15cee83388d34fbfa @emerleite committed Dec 19, 2011
Showing with 26 additions and 26 deletions.
  1. +26 −26 test/gravatar.test.js
View
@@ -1,32 +1,32 @@
-var testCase = require('nodeunit').testCase
+var should = require('should')
, url = require('url')
- , gravatar = require('../lib/gravatar')
- , baseURL = "http://www.gravatar.com/avatar/"
- , baseSecureURL = "https://secure.gravatar.com/avatar/";
+ , gravatar = require('../lib/gravatar');
-module.exports = testCase({
- 'it should gererate correct uri given an email': function(test) {
- test.equal(gravatar.url('emerleite@gmail.com'), baseURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
- test.equal(gravatar.url('emerleite@yahoo.com.br'), baseURL + "6c47672b0d58bd6aae4fa70920cb3ee4");
- test.done();
- },
- 'it should generate same uri ignoring case': function(test) {
- test.ok(gravatar.url('EMERLEITE@gmAil.com'), baseURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
- test.ok(gravatar.url('emerleite@YAHOO.com.BR'), baseURL + "6c47672b0d58bd6aae4fa70920cb3ee4");
- test.done();
- },
- 'it should generate uri with user passed parameters': function(test) {
+describe('gravatar', function() {
+ var baseURL = "http://www.gravatar.com/avatar/";
+ var baseSecureURL = "https://secure.gravatar.com/avatar/";
+
+ it('should gererate correct uri given an email', function() {
+ gravatar.url('emerleite@gmail.com').should.be.equal(baseURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
+ gravatar.url('emerleite@yahoo.com.br').should.be.equal(baseURL + "6c47672b0d58bd6aae4fa70920cb3ee4");
+ });
+
+ it('should generate same uri ignoring case', function() {
+ gravatar.url('EMERLEITE@gmAil.com').should.be.equal(baseURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
+ gravatar.url('emerleite@YAHOO.com.BR').should.be.equal(baseURL + "6c47672b0d58bd6aae4fa70920cb3ee4");
+ });
+
+ it('should generate uri with user passed parameters', function() {
var gravatarURL = gravatar.url('emerleite@gmail.com', { s: '200', f: 'y', r: 'g', d: '404'});
var queryString = url.parse(gravatarURL, true).query;
- test.equal(queryString.s, '200');
- test.equal(queryString.f, 'y');
- test.equal(queryString.r, 'g');
- test.equal(queryString.d, '404');
- test.done();
- },
- 'it should allow https gravatar uri generation': function(test) {
+ queryString.s.should.equal('200');
+ queryString.f.should.equal('y');
+ queryString.r.should.equal('g');
+ queryString.d.should.equal('404');
+ });
+
+ it('should allow https gravatar uri generation', function() {
var gravatarURL = gravatar.url('emerleite@gmail.com', {}, true);
- test.equal(gravatar.url('emerleite@gmail.com', {}, true), baseSecureURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
- test.done();
- }
+ gravatar.url('emerleite@gmail.com', {}, true).should.equal(baseSecureURL + "93e9084aa289b7f1f5e4ab6716a56c3b");
+ });
});

0 comments on commit 09f0446

Please sign in to comment.