Sha256: 32cb7eb2f28564722a719be88f7461e4c163b1a8244e19193b9b1340d3fb9351

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

var test = require('testling');
var timers = require('./builtins/timers');

test('setTimeout / clearTimeout', function (t) {
    t.plan(3);
    var arg1 = {}
    var arg2 = {}
    var async = false

    timers.setTimeout(function(param1, param2) {
      t.deepEqual(param1, arg1, '1st argument was curried');
      t.deepEqual(param2, arg2, '2nd argument was curried');
      t.ok(async, 'setTimeout is async');
      timers.clearTimeout(id);
    }, 10, arg1, arg2);

    var id = timers.setTimeout(function() {
      t.fail('timer had to be cleared');
    }, 50);

    timers.setTimeout(function() {
      t.end();
    }, 100);

    async = true;
});

test('setInterval / clearInterval', function (t) {
    t.plan(6);
    var arg1 = {};
    var arg2 = {};
    var called = 0;
    var async = false;

    var id = timers.setInterval(function(param1, param2) {
      called = called + 1;
      t.deepEqual(param1, arg1, '1st argument was curried');
      t.deepEqual(param2, arg2, '2nd argument was curried');
      t.ok(async, 'setInterval invokes internal async');

      if (called > 2) t.fail('internal had to be cleared')

      if (called === 2) {
        timers.clearInterval(id);
        t.end();
      }
    }, 5, arg1, arg2);

    async = true;
});

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
snowball-0.1.22 node_modules/browserify/testling/timers.js
sprockets-browserify-0.1.2 node_modules/browserify/testling/timers.js
sprockets-browserify-0.1.0 node_modules/browserify/testling/timers.js