From 9d625a31c3a45cd0d14c4a528cbb9847dce0e5e1 Mon Sep 17 00:00:00 2001 From: Jared Hanson Date: Tue, 13 Aug 2013 08:52:55 -0700 Subject: [PATCH] Switch InternalOAuthError test case to Mocha. --- test/errors/internaloautherror-test.js | 39 -------------------------- test/errors/internaloautherror.test.js | 30 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 test/errors/internaloautherror-test.js create mode 100644 test/errors/internaloautherror.test.js diff --git a/test/errors/internaloautherror-test.js b/test/errors/internaloautherror-test.js deleted file mode 100644 index a1d8d97..0000000 --- a/test/errors/internaloautherror-test.js +++ /dev/null @@ -1,39 +0,0 @@ -var vows = require('vows'); -var assert = require('assert'); -var util = require('util'); -var InternalOAuthError = require('../../lib/errors/internaloautherror'); - - -vows.describe('InternalOAuthError').addBatch({ - - 'when constructed with only a message': { - topic: function() { - return new InternalOAuthError('oops'); - }, - - 'should format message properly': function (err) { - assert.equal(err.toString(), 'oops'); - }, - }, - - 'when constructed with a message and error': { - topic: function() { - return new InternalOAuthError('oops', new Error('something is wrong')); - }, - - 'should format message properly': function (err) { - assert.equal(err.toString(), 'oops (Error: something is wrong)'); - }, - }, - - 'when constructed with a message and object with status code and data': { - topic: function() { - return new InternalOAuthError('oops', { statusCode: 401, data: 'invalid OAuth credentials' }); - }, - - 'should format message properly': function (err) { - assert.equal(err.toString(), 'oops (status: 401 data: invalid OAuth credentials)'); - }, - }, - -}).export(module); diff --git a/test/errors/internaloautherror.test.js b/test/errors/internaloautherror.test.js new file mode 100644 index 0000000..6d1e193 --- /dev/null +++ b/test/errors/internaloautherror.test.js @@ -0,0 +1,30 @@ +var InternalOAuthError = require('../../lib/errors/internaloautherror'); + + +describe('InternalOAuthError', function() { + + describe('constructed with a message', function() { + var err = new InternalOAuthError('oops'); + + it('should format correctly', function() { + expect(err.toString()).to.equal('oops'); + }); + }); + + describe('constructed with a message and error', function() { + var err = new InternalOAuthError('oops', new Error('something is wrong')); + + it('should format correctly', function() { + expect(err.toString()).to.equal('oops (Error: something is wrong)'); + }); + }); + + describe('constructed with a message and object with status code and data', function() { + var err = new InternalOAuthError('oops', { statusCode: 401, data: 'invalid OAuth credentials' }); + + it('should format correctly', function() { + expect(err.toString()).to.equal('oops (status: 401 data: invalid OAuth credentials)'); + }); + }); + +});