timers.js 1.14 KB
Newer Older
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 33 34
// if running on older node, ensure that es6-shim is loaded first
if (/^v0.10/.test(process.version)) { require('es6-shim'); }
var assert= require('../assert');
var timers = require('../timers');

describe('timers module', function() {
    it ('setImmediate()', function() {
        return timers.setImmediate().then(function(result) {
            assert.strictEqual(result, undefined, '');
        });
    });
    it ('setImmediate(<arg>)', function() {
        var obj = {};
        return timers.setImmediate(obj).then(function(result) {
            assert.strictEqual(result, obj, '');
        });
    });
    it ('setTimeout()', function() {
        return timers.setTimeout().then(function(result) {
            assert.strictEqual(result, undefined, '');
        });
    });
    it ('setTimeout(<num>)', function() {
        return timers.setTimeout(15).then(function(result) {
            assert.strictEqual(result, undefined, '');
        });
    });
    it ('setTimeout(<num>, <arg>)', function() {
        var obj = {};
        return timers.setTimeout(25, obj).then(function(result) {
            assert.strictEqual(result, obj, '');
        });
    });
});