1.0.1 • Published 9 years ago

socket-io-mock v1.0.1

Weekly downloads
422
License
ISC
Repository
github
Last release
9 years ago

socket-io-mock

NPM Build Status

A mock to test the socket.io library implementation

Installation

npm install socket-io-mock

Usage

Simply create new socket mock with:

var mockedSocket = new require('socket-io-mock')

And use the socket as if it was a normal Socket.io socket.

For example:

var SocketMock = require('socket-io-mock')
  , should = require('chai').should()

describe('Fast and isolated socket tests', function(){
  it('Sockets should be able to talk to each other without a server', function(done) {
    var socket = new SocketMock()
    
    socket.on('message', function (message) {
      message.should.be.equal('Hello World!')
    })
    socket.emit('message', 'Hello World!')
  })
})