<commit_before>/*global describe:true, it:true, before:true, after:true, beforeEach:true, afterEach:true */
var zmqstream = require('../lib/zmqstream')
  , expect = require('chai').expect
  , testSockets = []

function getInprocEndpoint() {
  return 'inproc://zmqstreamtest' + Math.random().toString().slice(2)
}

// A passthrough for the zmqstream.Socket constructor that caches all created sockets for cleanup.
function Socket(options) {
  var socket

  if (this instanceof Socket) {
    socket = new zmqstream.Socket(options)
  } else {
    socket = zmqstream.Socket(options)
  }

  testSockets.push(socket)
  return socket
}

process.on('exit', function () {
  testSockets.forEach(function (socket) {
    socket && socket.close()
  })
})

describe('ZMQStream', function () {
  it('should exist', function () {
    expect(zmqstream).to.exist
    expect(zmqstream).to.be.an('object')
  })

  describe('Constants', function () {
    it('should exist', function () {
      expect(zmqstream.Type).to.exist
      expect(zmqstream.Type).to.be.an('object')
    })

    it('should export all socket types', function () {
      expect(zmqstream.Type.REQ, 'REQ').to.exist
      expect(zmqstream.Type.REP, 'REP').to.exist
      expect(zmqstream.Type.DEALER, 'DEALER').to.exist
      expect(zmqstream.Type.ROUTER, 'ROUTER').to.exist
      expect(zmqstream.Type.PUB, 'PUB').to.exist
      expect(zmqstream.Type.SUB, 'SUB').to.exist
      expect(zmqstream.Type.XPUB, 'XPUB').to.exist
      expect(zmqstream.Type.XSUB, 'XSUB').to.exist
      expect(zmqstream.Type.PUSH, 'PUSH').to.exist
      expect(zmqstream.Type.PULL, 'PULL').to.exist
      expect(zmqstream.Type.PAIR, 'PAIR').to.exist
    })
  })

  describe('Socket', function () {
    it('should exist', function () {
      expect(zmqstream.Socket).to.exist
      expect(zmqstream.Socket).to.be.a('function')<commit_msg>Added tests for options.<commit_after>/*global describe:true, it:true, before:true, after:true, beforeEach:true, afterEach:true */
var zmqstream = require('../lib/zmqstream')
  , expect = require('chai').expect
  , testSockets = []

function getInprocEndpoint() {
  return 'inproc://zmqstreamtest' + Math.random().toString().slice(2)
}

// A passthrough for the zmqstream.Socket constructor that caches all created sockets for cleanup.
function Socket(options) {
  var socket

  if (this instanceof Socket) {
    socket = new zmqstream.Socket(options)
  } else {
    socket = zmqstream.Socket(options)
  }

  testSockets.push(socket)
  return socket
}

process.on('exit', function () {
  testSockets.forEach(function (socket) {
    socket && socket.close()
  })
})

describe('ZMQStream', function () {
  it('should exist', function () {
    expect(zmqstream).to.exist
    expect(zmqstream).to.be.an('object')
  })

  describe('Constants', function () {
    it('should exist', function () {
      expect(zmqstream.Type).to.exist
      expect(zmqstream.Type).to.be.an('object')
      expect(zmqstream.Option).to.exist
      expect(zmqstream.Option).to.be.an('object')
    })

    it('should export all socket types', function () {
      expect(zmqstream.Type.REQ, 'REQ').to.exist
      expect(zmqstream.Type.REP, 'REP').to.exist
      expect(zmqstream.Type.DEALER, 'DEALER').to.exist
      expect(zmqstream.Type.ROUTER, 'ROUTER').to.exist
      expect(zmqstream.Type.PUB, 'PUB').to.exist
      expect(zmqstream.Type.SUB, 'SUB').to.exist
      expect(zmqstream.Type.XPUB, 'XPUB').to.exist
      expect(zmqstream.Type.XSUB, 'XSUB').to.exist
      expect(zmqstream.Type.PUSH, 'PUSH').to.exist
      expect(zmqstream.Type.PULL, 'PULL').to.exist
      expect(zmqstream.Type.PAIR, 'PAIR').to.exist
    })

    it('should export all available options', function () {
      expect(zmqstream.Option.TYPE, 'TYPE').to.exist
      expect(zmqstream.Option.IDENTITY, 'IDENTITY').to.exist
      expect(zmqstream.Option.SUBSCRIBE, 'SUBSCRIBE').to.exist
      expect(zmqstream.Option.UNSUBSCRIBE, 'UNSUBSCRIBE').to.exist
      expect(zmqstream.Option.LINGER, 'LINGER').to.exist
      // TODO: Support and test other options.
    })
  })

  describe('Socket', function () {
    it('should exist', function () {
      expect(zmqstream.Socket).to.exist
      expect(zmqstream.Socket).to.be.a('function')
{'fraction_non_alphanumeric': 0.160188457008245, 'fraction_numerical': 0.0004711425206124853, 'mean_word_length': 3.6052060737527114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4073610', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1439, 'n_words': 232}