require('./setup'); var stat = require('../model/stat'); var _ = require('lodash'); var Promise = require('bluebird'); var fs = require('fs'); describe('Stat Model', function() { var validData = [ {key: 'a', threshold: 2, threshold_inv: 1}, {key: 'b', threshold: 2}, {key: 'c', threshold_inv: 1}, {key: 'd', threshold: 2} ] var stat_object = new stat('./log_test/', {rotation:5000, maxsize:5000, interval:1, data:validData}) before(function(done) { validData = ['a', 'b']; done(); }); it('should stat correctly (whole process)', function(done) { stat_object.start(); return Promise.delay(100) .then(function() { Promise.all(_.map(_.times(100, String), function(){ stat_object.increment(validData[0]); })) }) .then(function() { return Promise.delay(100) }) .then(function() { stat_object.increment(validData[0]); stat_object.increment(validData[1]); }) .then(function() { return Promise.delay(100) }) .then(function() { stat_object.stop(); done(); }) }); });