/**
 * Created by TalhaAkkas on 12/08/15.
 */
/**
 * Created by TalhaAkkas on 12/08/15.
 */

var should = require('should');
var utils = require('../utils');
var WaitingFunction = utils.WaitingFunction;

//var usageLimit = options.usageLimit || -1;
//var data = options.data || {};
//var key = options.key || DEFAULT_QUEUE_KEY;
//var that = options.that || null;
//var path = options.path || __dirname + '/childThread.js';
//var jobID = options.jobID ||"<id>" + new Date().getTime() + "<rand>" + Math.random() + "<id>";
//var meta = options.meta || {}

describe('Threads Tests', function () {
	it('should return from job when finished', function (done) {
		var a = 0;
		var waiting = new WaitingFunction();
		for(var i = 0; i < 10; i++){
			setTimeout( waiting.getCbToWait(), Math.random() * 2000);
		}
		waiting.cb = function(){
			//console.log("they called all");
			done();
		}
	});


	it('should utils.mergeByTime list', function (done) {
		var geoList = [];
		var eventList = [];
		for(var i = 0; i < 500; i++){
			geoList.push({type:"GEO", eventNo:i});
		}
		for(var i = 0; i < 500; i += 10){
			eventList.push({type:"EVENT", eventNo:i});
		}
		var mergeList = utils.mergeByTime(geoList, eventList, function(item){return item.eventNo}, function(item){return item.eventNo});
		console.log(mergeList);
	});


});