summaryrefslogtreecommitdiff
path: root/mocha_test/apply.js
blob: 18e5d127978119fdfaca6b9a9cf59d1947d8acb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var async = require('../lib');
var expect = require('chai').expect;

describe('concat', function() {
    it('apply', function(done) {
        var fn = function(){
            expect(Array.prototype.slice.call(arguments)).to.eql([1,2,3,4]);
        };
        async.apply(fn, 1, 2, 3, 4)();
        async.apply(fn, 1, 2, 3)(4);
        async.apply(fn, 1, 2)(3, 4);
        async.apply(fn, 1)(2, 3, 4);
        async.apply(fn)(1, 2, 3, 4);
        expect(
            async.apply(function(name){return 'hello ' + name;}, 'world')()
        ).to.equal(
            'hello world'
        );
        done();
    });
});