1.1.1 • Published 10 years ago

angular-ws-mock v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

angular-ws-mock

Build Status Dependency Status devDependency Status

Mock for AngularJS WebSocket service.

Install

bower install angular-ws-mock

Usage

describe('My service', function () {
  var ws, myService;

  beforeEach(module('app', 'wsMock'));

  beforeEach(inject(function ($injector) {
    ws = $injector.get('ws');
    myService = $injector.get('myService');
  }));

  it('should connect to the WebSocket', function () {
    ws.emit('open');

    expect(ws.getReadyState()).to.equal(1);
  });

ws.emit(event, data)

Emit a new event.

ws.emit('message', {data: 'my message'});

ws.messages

Read the messages sent.

ws.send('hello')
console.log(ws.messages); // ['hello']

ws.reset()

Empty messages.

ws.send('hello')
console.log(ws.messages); // ['hello']
ws.reset();
console.log(ws.messages); // []

License

MIT

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago