var async = require('../lib');
var assert = require('assert');
var expect = require('chai').expect;
var isBrowser = require('./support/is_browser');

describe('asyncify', function(done){

    it('asyncify', function(done) {
        var parse = async.asyncify(JSON.parse);
        parse("{\"a\":1}", function (err, result) {
            assert(!err);
            assert(result.a === 1);
            done();
        });
    });

    it('asyncify null', function(done) {
        var parse = async.asyncify(function() {
            return null;
        });
        parse("{\"a\":1}", function (err, result) {
            assert(!err);
            assert(result === null);
            done();
        });
    });

    it('variable numbers of arguments', function(done) {
         async.asyncify(function (x, y, z) {
             return arguments;
         })(1, 2, 3, function (err, result) {
             expect(result.length).to.equal(3);
             expect(result[0]).to.equal(1);
             expect(result[1]).to.equal(2);
             expect(result[2]).to.equal(3);
             done();
         });
     });

    it('catch errors', function(done) {
        async.asyncify(function () {
            throw new Error("foo");
        })(function (err) {
            assert(err);
            assert(err.message === "foo");
            done();
        });
    });

    it('dont catch errors in the callback', function(done) {
        try {
            async.asyncify(function () {})(function (err) {
                if (err) {
                    return done(new Error("should not get an error here"));
                }
                throw new Error("callback error");
            });
        } catch (e) {
            assert(e.message === "callback error");
            done();
        }
    });

    describe('promisified', function() {
        if (isBrowser()) {
            // node only tests
            return;
        }

        var names = [
            'native-promise-only',
            'bluebird',
            'es6-promise',
            'rsvp'
        ];

        names.forEach(function(name) {
            describe(name, function() {

                var Promise = require(name);
                if (typeof Promise.Promise === 'function') {
                    Promise = Promise.Promise;
                }

                it('resolve', function(done) {
                    var promisified = function(argument) {
                        return new Promise(function (resolve) {
                            setTimeout(function () {
                                resolve(argument + " resolved");
                            }, 15);
                        });
                    };
                    async.asyncify(promisified)("argument", function (err, value) {
                        if (err) {
                            return done(new Error("should not get an error here"));
                        }
                        assert(value === "argument resolved");
                        done();
                    });
                });

                it('reject', function(done) {
                    var promisified = function(argument) {
                        return new Promise(function (resolve, reject) {
                            reject(argument + " rejected");
                        });
                    };
                    async.asyncify(promisified)("argument", function (err) {
                        assert(err);
                        assert(err.message === "argument rejected");
                        done();
                    });
                });
            });
        });
    });
});

@@ -347,37 +347,37 @@
 r);%0A            
-asser
+expec
 t(result.a === 1
@@ -370,21 +370,27 @@
 result.a
- === 
+).to.equal(
 1);%0A    
@@ -646,21 +646,21 @@
     
-asser
+expec
 t(result
  ===
@@ -655,21 +655,27 @@
 t(result
- === 
+).to.equal(
 null);%0A 
@@ -1287,37 +1287,37 @@
 r);%0A            
-asser
+expec
 t(err.message ==
@@ -1313,21 +1313,27 @@
 .message
- === 
+).to.equal(
 %22foo%22);%0A
@@ -1714,16 +1714,18 @@
 catch (e
+rr
 ) %7B%0A    
@@ -1736,24 +1736,26 @@
     
-asser
+expec
 t(e
+rr
 .message
  ===
@@ -1750,21 +1750,27 @@
 .message
- === 
+).to.equal(
 %22callbac
@@ -2972,25 +2972,31 @@
     
-asser
+expec
 t(value
- === 
+).to.equal(
 %22arg
@@ -3512,29 +3512,29 @@
             
-asser
+expec
 t(err.messag
@@ -3534,21 +3534,27 @@
 .message
- === 
+).to.equal(
 %22argumen

Replace assert with expect to ease debug