exec('rm -rf ' + temp, function (err) { if (err) return done(err) fs.mkdirSync(temp) fs.writeFileSync(testConfPath, testConf.replace('{{root}}', root)) pod = jsc.require(module, '../lib/api') pod.once('ready', done) })
// Call the jsCoverage module. This will enable the jsc.require() // to run the injection calls into the codebase before the Jasmine // tests are executed. if (typeof module !== 'undefined' && module.exports) { var jsc = require('jscoverage'); var util = jsc.require(module, '../src.js'); var util2 = jsc.require(module, '../src2.js'); } // Ok, get the actual source code. describe('simpleIncrement', function() { // This checks that the pad function will // pad both a string and an number which // are smaller then required length. describe('pad to 3 characters', function() { it('Increment by 1', function () { expect( util.simpleIncrement( 1 ) ).toBe( 2 ); }); it('Increment by 5', function () { expect( util.simpleIncrement( 5, 5 ) ).toBe( 10 ); }); });
/** * Module dependencies. */ var JSCOV = process.env.JSCOV === '1'; if (JSCOV) { var jscoverage = require('jscoverage'); require = jscoverage.require(module); } var urllib = require('../', JSCOV); var should = require('should'); var http = require('http'); /* {{{ private function implode_buffer_chunks() */ function implode_buffer_chunks(chunks) { var len = 0; for (var i = 0; i < chunks.length; i++) { len += chunks[i].length; } var pos = 0; var buf = new Buffer(len); for (var i = 0; i < chunks.length; i++) { chunks[i].copy(buf, pos); pos += chunks[i].length; } return buf; } /* }}} */
var should = require('should'); var EventEmitter = require('events').EventEmitter; var jsc = require('jscoverage'); var OrderedEventEmitter = jsc.require(module, '../OrderedEventEmitter.js'); describe("Ordered Event Emitter", function() { it("Is an EventEmitter", function() { ((new OrderedEventEmitter()) instanceof EventEmitter).should.be.true; }); it("Adds listeners in a way that EventEmitter understands", function() { var emitter = new OrderedEventEmitter(); emitter.listeners('test').length.should.be.exactly(0); emitter.addListenerFirst('test', function() {}); emitter.listeners('test').length.should.be.exactly(1); emitter.addListenerFirst('test', function() {}); emitter.listeners('test').length.should.be.exactly(2); emitter.addListenerFirst('test', function() {}); emitter.listeners('test').length.should.be.exactly(3); }); it("Allows injecting listeners first", function(done) { var values = []; var emitter = new OrderedEventEmitter(); function checkDone() { if (values.length < 2) return; values[0].should.be.exactly('first'); values[1].should.be.exactly('on'); done();
var jscoverage = require('jscoverage'); jscoverage.enableCoverage(true); var coveralls = require('coveralls'); var redisManager = jscoverage.require(module, '../lib/redis-manager'); exports.sameClientIsSame = function(test) { test.expect(1); var client1 = redisManager.getClient(); var client2 = redisManager.getClient(); test.equal(client1.__id__, client2.__id__); redisManager.freeClient(client1); redisManager.freeClient(client2); test.done(); }; exports.differentClientIsDifferent = function(test) { test.expect(1); var client1 = redisManager.getClient(); var client2 = redisManager.getClient(6379, 'localhost'); test.notEqual(client1, client2); redisManager.freeClient(client1); redisManager.freeClient(client2); test.done(); }; exports.freeClients = function(test) { test.expect(4); var client = redisManager.getClient(); test.equal(true, redisManager.freeClient(client)); test.equal(false, redisManager.freeClient(client)); var client1 = redisManager.getClient();
var q = require('queue-flow'); var jscoverage = require('jscoverage'); jscoverage.enableCoverage(true); var sloppy = jscoverage.require(module, '../lib/sloppy-queue-flow'); exports.sloppyType = function(test) { test.expect(3); test.ok(!!sloppy.prototype); test.ok(!!(new sloppy().map)); test.ok(!!q(undefined, sloppy).map); test.done(); }; exports.sloppy = function(test) { test.expect(3); q([1, 2, 3, 4, 5]) .map(function(val) { return val*2; }) .toArray(function(outArr) { test.equal([2, 4, 6, 8, 10].toString(), outArr.toString(), 'queue-flow is behaving properly'); }); q([1, 2, 3, 4, 5], sloppy) .map(function(val, callback) { setTimeout(callback.bind(this, val*2), 1000/val); }) .toArray(function(outArr) { test.notEqual([2, 4, 6, 8, 10].toString(), outArr.toString(), 'sloppy-queue-flow passes along results on a first-done basis'); test.equal([2, 4, 6, 8, 10].toString(), outArr.sort(function(a,b) { return a-b; }).toString(), 'sloppy-queue-flow passes along all values'); test.done(); });