summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbspates <bxs4361@g.rit.edu>2016-04-04 19:01:35 -0700
committerbspates <bxs4361@g.rit.edu>2016-04-04 19:01:35 -0700
commit45841e7280b44d400ee32a51edba5c2d67c66436 (patch)
tree9d6a23a4d243f08066a318b296eef37d54460ccf
parent7228698be53e771006ee36cbf0638e037746c023 (diff)
downloadasync-45841e7280b44d400ee32a51edba5c2d67c66436.tar.gz
update unit tests to test issue through ensureAsync, not helper method
-rw-r--r--mocha_test/ensureAsync.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/mocha_test/ensureAsync.js b/mocha_test/ensureAsync.js
index 2cfc749..37f9549 100644
--- a/mocha_test/ensureAsync.js
+++ b/mocha_test/ensureAsync.js
@@ -1,26 +1,32 @@
-import initialParams from '../lib/internal/initialParams';
+var async = require('../lib');
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);
- };
+describe('ensureAsync', function() {
+ var passContext = function(cb) {
+ cb(this);
+ };
+
+ it('should propely bind context to the wrapped function', function(done) {
// call bind after wrapping with initialParams
- var contextOne = {context: "one"};
- var postBind = initialParams(passContext);
- postBind = postBind.bind(contextOne);
- postBind([], function(ref) {
- expect(ref).to.equal(contextOne);
+ var context = {context: "post"};
+ var postBind = async.ensureAsync(passContext);
+ postBind = postBind.bind(context);
+ postBind(function(ref) {
+ expect(ref).to.equal(context);
+ done();
});
+ });
+
+ it('should not override the bound context of a function when wrapping', function(done) {
// call bind before wrapping with initialParams
- var contextTwo = {context: "two"};
- var preBind = passContext.bind(contextTwo);
- preBind = initialParams(preBind);
- preBind([], function(ref) {
- expect(ref).to.equal(contextTwo);
+ var context = {context: "pre"};
+ var preBind = passContext.bind(context);
+ preBind = async.ensureAsync(preBind);
+ preBind(function(ref) {
+ expect(ref).to.equal(context);
+ done();
});
});
});