diff options
author | bspates <bxs4361@g.rit.edu> | 2016-04-03 17:23:00 -0700 |
---|---|---|
committer | bspates <bxs4361@g.rit.edu> | 2016-04-03 17:23:00 -0700 |
commit | 51157c1ad38d9d88e4be9f61a17d25bd710ca68f (patch) | |
tree | 759fb0608b4217f2cbd2a5e794d74c2b561584f9 | |
parent | 04c554894f95c5cb043167a0d54f81396bb73f1c (diff) | |
download | async-51157c1ad38d9d88e4be9f61a17d25bd710ca68f.tar.gz |
add unit test for context curring when using initialParams
-rw-r--r-- | mocha_test/initialParams.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mocha_test/initialParams.js b/mocha_test/initialParams.js new file mode 100644 index 0000000..5a03ffc --- /dev/null +++ b/mocha_test/initialParams.js @@ -0,0 +1,26 @@ +var initialParams = require('../lib/internal/initialParams');
+var expect = require('chai').expect;
+
+describe('initialParams', function() {
+ it('should curry any bound context to the wrapped function', function() {
+ var passContext = function(args, cb) {
+ cb(this);
+ };
+
+ // call bind after wrapping with initialParams
+ var contextOne = {context: "one"};
+ var postBind = initialParams.default(passContext);
+ postBind = postBind.bind(contextOne);
+ postBind([], function(ref) {
+ expect(ref).to.equal(contextOne);
+ });
+
+ // call bind before wrapping with initialParams
+ var contextTwo = {context: "two"};
+ var preBind = passContext.bind(contextTwo);
+ preBind = initialParams.default(preBind);
+ preBind([], function(ref) {
+ expect(ref).to.equal(contextTwo);
+ });
+ });
+});
|