Skip to content

Commit

Permalink
#1031 Updated unit tests. Included undesirable hack for documenting b…
Browse files Browse the repository at this point in the history
…ehavior between v4 and v5
  • Loading branch information
brianhyder committed May 9, 2016
1 parent a0370eb commit 699237d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions include/util.js
Expand Up @@ -118,7 +118,7 @@ Util.escapeRegExp = function(str) {
* @return {Object} The 'to' variable
*/
Util.merge = function(from, to) {
Util.forEach(from, function(val, propName/*, */) {
Util.forEach(from, function(val, propName) {
to[propName] = val;
});
return to;
Expand Down Expand Up @@ -213,7 +213,7 @@ Util.forEach = function(iterable, handler) {
}
else {
return false;
};
}

//execute native foreach on interable
internalIterable.forEach(internalHandler);
Expand Down Expand Up @@ -660,7 +660,7 @@ Util.mkdirs = function(absoluteDirPath, isFileName, cb) {
});
};
});
async.series(tasks, function(err, results){
async.series(tasks, function(err/*, results*/){
cb(err);
});
};
Expand Down
20 changes: 16 additions & 4 deletions test/include/util_tests.js
@@ -1,5 +1,7 @@

//dependencies
var process = require('process');
var semver = require('semver');
var async = require('async');
var should = require('should');
var path = require('path');
Expand Down Expand Up @@ -1056,17 +1058,27 @@ describe('Util', function() {
Type3.staticFunc.should.eql(staticFuncFor3);
});

it('prototype functions of the inheriting type that do not exist on the super prototype should remain in tact', function() {
Type3.prototype.getAll.should.eql(getAll);
});

it('prototype functions of the super type that are not implemented by the inheriting type should be inherited', function() {
Type3.prototype.set.should.eql(Type1.prototype.set);
});

it('prototype functions of the inheriting type should not be overriden by the super type', function() {
Type3.prototype.get.should.eql(Type3.prototype.get);
});

//I hate myself for this but there is a breaking change between v4 and v5 that causes a difference in behavior.
// Documenting it as a unit test.
var nodeVersion = semver.clean(process.version);
if (semver.satisfies(nodeVersion, '>=5')) {
it('Node >= 5 - prototype functions of the inheriting type that do not exist on the super prototype should remain in tact', function() {
Type3.prototype.getAll.should.eql(getAll);
});
}
else {
it('Node < 5 - prototype functions of the inheriting type that do not exist on the super prototype should not remain in tact', function() {
should(Type3.prototype.getAll).eql(undefined);
});
}
});
});
});
Expand Down

0 comments on commit 699237d

Please sign in to comment.