New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-ws-mock

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-ws-mock

Mock for AngularJS WebSocket service.

1.1.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 11 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts