summaryrefslogtreecommitdiff
path: root/test/setImmediate.js
blob: 6e4a400de17e2023684f47b13ef07834246687d6 (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
var async = require('../lib');
var expect = require('chai').expect;

describe("setImmediate", () => {

    it('basics', (done) => {
        var call_order = [];
        async.setImmediate(() => {call_order.push('two');});
        call_order.push('one');

        setTimeout(() => {
            expect(call_order).to.eql(['one','two']);
            done();
        }, 25);
    });

    it("extra args", (done) => {
        async.setImmediate((a, b, c) => {
            expect([a, b, c]).to.eql([1, 2, 3]);
            done();
        }, 1, 2, 3);
    });

});