blob: 0aecee67d89e54922dc0fa90fe562e52f83cf593 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
var async = require('../lib');
var expect = require('chai').expect;
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 ensureAsync
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 ensureAsync
var context = {context: "pre"};
var preBind = passContext.bind(context);
preBind = async.ensureAsync(preBind);
preBind(function(ref) {
expect(ref).to.equal(context);
done();
});
});
});
|