glemmaPaul / socket-io-mock

A mock to test the socket.io library implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

socket-io-mock

Build Status npm version

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.socketClient.emit('message', 'Hello World!')
  })
})

About

A mock to test the socket.io library implementation


Languages

Language:JavaScript 100.0%