diff --git a/test/main.test.js b/test/main.test.js index dc85675..29a4d16 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -108,31 +108,25 @@ describe('LoopBack Context', function() { function(done) { expect(require('async/package.json').version).to.equal('1.5.2'); LoopBackContext.runInContext(function() { - // function 1 which pulls context - var fn1 = function(cb) { - var ctx = LoopBackContext.getCurrentContext(); - expect(ctx).is.an('object'); - ctx.set('test-key', 'test-value'); - cb(); - }; - // function 2 which pulls context - var fn2 = function(cb) { - var ctx = LoopBackContext.getCurrentContext(); - expect(ctx).is.an('object'); - var testValue = ctx && ctx.get('test-key', 'test-value'); - cb(null, testValue); - }; // Trigger async waterfall callbacks - var asyncFn = function() { - async.waterfall([ - fn1, - fn2, - ], function(err, testValue) { + async.waterfall([ + function pushToContext(next) { + var ctx = LoopBackContext.getCurrentContext(); + expect(ctx).is.an('object'); + ctx.set('test-key', 'test-value'); + next(); + }, + function pullFromContext(next) { + var ctx = LoopBackContext.getCurrentContext(); + expect(ctx).is.an('object'); + var testValue = ctx && ctx.get('test-key', 'test-value'); + next(null, testValue); + }, + function verify(testValue, next) { expect(testValue).to.equal('test-value'); - done(); - }); - }; - asyncFn(); + next(); + }, + ], done); }); }); });