UNPKG

itsa-utils

Version:

ITSA's utility functions

43 lines (36 loc) 1.05 kB
/*global describe, it */ /*jshint unused:false */ "use strict"; var expect = require("chai").expect; Object.prototype.each = function (fn, context) { for (var key in this) { if (this.hasOwnProperty(key)) { fn.call(context, this[key], key, this); } } return this; }; var timers = require("../index.js"), merge = function (obj1, obj2) { obj2.each(function (value, key) { if (!(key in obj1)) { obj1[key] = obj2[key]; } }); }; describe("Testing later-method with long timeout", function () { this.timeout(10000); describe("without repeat", function () { it("later", function (done) { var count = 0; timers.later(function() { count++; }, 1000); // purposly, check after >2x timeout --> count should only increase 1x setTimeout(function() { expect(count).to.eql(1); done(); }, 2080); }); }); });