Permalink
Browse files

Improving error message testing.

  • Loading branch information...
1 parent 0926b81 commit aa3923a6bdb7d622a99a0a74ccc3e3d40a449114 Andre Rodrigues committed Oct 10, 2012
Showing with 20 additions and 5 deletions.
  1. +2 −2 lib/services/core/connectionstringparser.js
  2. +18 −3 test/services/core/connectionstringparser-tests.js
@@ -22,7 +22,7 @@ exports = module.exports;
* Creates a new 'ConnectionString' instance.
*
* @constructor
-* @param {number} connectionString The connection string to be parsed.
+* @param {string} connectionString The connection string to be parsed.
*/
function ConnectionStringParser(connectionString) {
this._value = connectionString;
@@ -78,7 +78,7 @@ ConnectionStringParser.prototype._parse = function () {
if (this._state === 'ExpectAssignment') {
// Must end parsing in the valid state (expected key or separator)
- throw new Error('Invalid connection string. Missing character "=".');
+ throw new Error('Missing character "="');
}
return parsedConnectionString;
@@ -49,7 +49,12 @@ suite('connectionstringparser-tests', function () {
function() {
var parsedConnectionString = ConnectionStringParser.parse('Endpoint');
},
- Error
+ function(err) {
+ if ((err instanceof Error) && err.message === 'Missing character "="') {
+ return true;
+ }
+ },
+ "unexpected error"
);
done();
@@ -60,14 +65,24 @@ suite('connectionstringparser-tests', function () {
function() {
var parsedConnectionString = ConnectionStringParser.parse('=value');
},
- Error
+ function(err) {
+ if ((err instanceof Error) && err.message === 'Missing key') {
+ return true;
+ }
+ },
+ "unexpected error"
);
assert.throws(
function() {
var parsedConnectionString = ConnectionStringParser.parse(' =value');
},
- Error
+ function(err) {
+ if ((err instanceof Error) && err.message === 'Missing key') {
+ return true;
+ }
+ },
+ "unexpected error"
);
done();

0 comments on commit aa3923a

Please sign in to comment.