Code coverage report for nock/lib/socket.js

Statements: 96.3% (26 / 27)      Branches: 80% (8 / 10)      Functions: 100% (5 / 5)      Lines: 96.3% (26 / 27)      Ignored: none     

All files » nock/lib/ » socket.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51    1     1   1 452   452   452 42     452 452   452 452 9 9   452 2 1 1 1               452 452 452   452   452     1   1 1    
'use strict';
 
var EventEmitter = require('events').EventEmitter,
    debug        = require('debug')('nock.socket');
 
module.exports = Socket;
 
function Socket(options) {
  var socket = new EventEmitter();
 
  options = options || {};
 
  if (options.proto === 'https') {
    socket.authorized = true;
  }
 
  socket.writable = true;
  socket.readable = true;
 
  socket.setNoDelay = noop;
  socket.setTimeout = function(timeout, fn) {
    this.timeout = timeout;
    this.timeoutFunction = fn;
  }
  socket._checkTimeout = function(delay) {
    if (this.timeout && delay > this.timeout) {
      debug('socket timeout');
      Eif (this.timeoutFunction) {
        this.timeoutFunction();
      }
      else {
        this.emit('timeout');
      }
    }
  }
 
  socket.setKeepAlive = noop;
  socket.destroy = noop;
  socket.resume = noop;
 
  socket.getPeerCertificate = getPeerCertificate;
 
  return socket;
}
 
function noop() {}
 
function getPeerCertificate() {
  return new Buffer((Math.random() * 10000 + Date.now()).toString()).toString('base64');
}