-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"use strict"; | ||
|
||
var should = require('should'); | ||
var rarity = require('../lib/'); | ||
|
||
describe('rarity.carry()', function() { | ||
var EXPECTED_RESULT = "expectedResult"; | ||
|
||
var noop = function() {}; | ||
|
||
it("should fail with non array", function(done) { | ||
try { | ||
rarity.carry("nope", noop); | ||
} | ||
catch(e) { | ||
e.toString().should.containDeep('must be an array'); | ||
return done(); | ||
} | ||
|
||
done(new Error("Should not be working")); | ||
}); | ||
|
||
it.only("should fail without function as second argument", function(done) { | ||
try { | ||
rarity.carry([], 4); | ||
} | ||
catch(e) { | ||
e.toString().should.containDeep('must be a function'); | ||
return done(); | ||
} | ||
|
||
done(new Error("Should not be working")); | ||
}); | ||
|
||
it("should carry arguments", function(done) { | ||
var original = function(cb) { | ||
cb('error', EXPECTED_RESULT); | ||
}; | ||
|
||
original(rarity.carry(['carry'], function(c1, c2, c3) { | ||
c1.should.eql('error'); | ||
c2.should.eql('carry'); | ||
c3.should.eql(EXPECTED_RESULT); | ||
arguments.should.have.lengthOf(3); | ||
done(); | ||
})); | ||
}); | ||
|
||
it("should carry arguments when cb only launch err", function(done) { | ||
var original = function(cb) { | ||
cb('error'); | ||
}; | ||
|
||
original(rarity.carry(['carry'], function(c1, c2) { | ||
c1.should.eql('error'); | ||
c2.should.eql('carry'); | ||
arguments.should.have.lengthOf(2); | ||
|
||
done(); | ||
})); | ||
}); | ||
|
||
it("should carry arguments when cb don't render anything", function(done) { | ||
var original = function(cb) { | ||
cb(); | ||
}; | ||
|
||
original(rarity.carry(['carry'], function(c1, c2) { | ||
c1.should.eql(null); | ||
c2.should.eql('carry'); | ||
arguments.should.have.lengthOf(2); | ||
|
||
done(); | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters