<commit_before>import {connect} from '../src/index'
const expect = require('chai').expect

const dummyProtocol = (config, register, dispatch) => {
  setTimeout(() => {
    if (config.multipleParams) {
      dispatch('test event', {success: true}, false)
    } else {
      dispatch('test event', {success: true})
    }
  }, 5)
}

describe('coffea.connect', () => {
  describe('core functionality', () => {
    it('should return an error if protocol is not defined', (done) => {
      expect(() => { connect({}) }).to.throw

      done()
    })

    it('should return an error if the protocol is not a function or a string', (done) => {
      expect(() => { connect({ protocol: 4 }) }).to.throw

      done()
    })

    it('should return an error if the protocol can not be found', (done) => {
      expect(() => { connect({ protocol: 'somestupidprotocolthatshouldntexist' }) }).to.throw

      done()
    })

    it('should return an object with two functions - "on" and "call"', (done) => {
      let c = connect({
        protocol: dummyProtocol
      })

      expect(c.on).to.exist
      expect(c.call).to.exist

      done()
    })
  })

  describe('event dispatcher', () => {<commit_msg>add random number to `unknown protocol` test<commit_after>import {connect} from '../src/index'
const expect = require('chai').expect

const dummyProtocol = (config, register, dispatch) => {
  setTimeout(() => {
    if (config.multipleParams) {
      dispatch('test event', {success: true}, false)
    } else {
      dispatch('test event', {success: true})
    }
  }, 5)
}

describe('coffea.connect', () => {
  describe('core functionality', () => {
    it('should return an error if protocol is not defined', (done) => {
      expect(() => { connect({}) }).to.throw

      done()
    })

    it('should return an error if the protocol is not a function or a string', (done) => {
      expect(() => { connect({ protocol: 4 }) }).to.throw

      done()
    })

    it('should return an error if the protocol can not be found', (done) => {
      expect(() => { connect({ protocol: 'somestupidprotocolthatshouldntexist' + Math.floor(Math.random() * 999) }) }).to.throw

      done()
    })

    it('should return an object with two functions - "on" and "call"', (done) => {
      let c = connect({
        protocol: dummyProtocol
      })

      expect(c.on).to.exist
      expect(c.call).to.exist

      done()
    })
  })

  describe('event dispatcher', () => {
{'fraction_non_alphanumeric': 0.17366490012229924, 'fraction_numerical': 0.0028536485935589076, 'mean_word_length': 2.7812018489984593, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '1496435', 'n_tokens_mistral': 742, 'n_tokens_neox': 716, 'n_words': 214}