Server : nginx/1.18.0 System : Linux localhost 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64 User : www-data ( 33) PHP Version : 8.0.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/ecommerce/node_modules/pusher-js/spec/javascripts/integration/web/dom/ |
var Pusher = require('pusher_integration');
window.Pusher = Pusher;
var Integration = require("integration");
var JSONPRequest = require('dom/jsonp_request').default;
Integration.describe("JSONP", function() {
it("should send a request and receive a correct response", function() {
var callback = jasmine.createSpy();
var receiver = Pusher.ScriptReceivers.create(callback);
var url = Integration.API_URL + "/v2/jsonp/echo";
var request;
runs(function() {
request = new JSONPRequest(url, {
"session": 2289545,
"features": ["ws", "sockjs"],
"version": "1.13.0",
"t0": 1355850357911,
"timeline": [
{ t: 0, e: 2 },
{ t: 2, e: 2, type: "ws" },
{ t: 1001, e: 4, type: "ws" },
{ t: 1001, e: 0, type: "sockjs" },
{ t: 2000, e: 5 },
{ t: 2158, e: 1, type: "sockjs" },
{ t: 2378, e: 2, type: "sockjs" },
{ t: 3892, e: 3, type: "sockjs" },
{ t: 3892, e: 3 }
]
});
request.send(receiver);
});
waitsFor(function() {
return callback.calls.length > 0;
}, "JSONP to respond", 5000);
runs(function() {
expect(callback.calls.length).toEqual(1);
expect(callback).toHaveBeenCalledWith(null, {
"session": "2289545",
"features": ["ws", "sockjs"],
"version": "1.13.0",
"t0": "1355850357911",
"timeline": [
{ t: 0, e: 2 },
{ t: 2, e: 2, type: "ws" },
{ t: 1001, e: 4, type: "ws" },
{ t: 1001, e: 0, type: "sockjs" },
{ t: 2000, e: 5 },
{ t: 2158, e: 1, type: "sockjs" },
{ t: 2378, e: 2, type: "sockjs" },
{ t: 3892, e: 3, type: "sockjs" },
{ t: 3892, e: 3 }
]
});
request.cleanup()
});
});
it("should call back without a result on 404 response", function() {
var callback = jasmine.createSpy();
var receiver = Pusher.ScriptReceivers.create(callback);
var url = Integration.API_URL + "/jsonp/404";
var request;
runs(function() {
request = new JSONPRequest(url, {});
request.send(receiver);
});
waitsFor(function() {
return callback.calls.length > 0;
}, "JSONP to respond", 5000);
runs(function() {
expect(callback.calls.length).toEqual(1);
expect(callback.calls[0].args[1]).toBe(undefined);
request.cleanup();
});
});
it("should call back without a result on 500 response", function() {
var callback = jasmine.createSpy();
var receiver = Pusher.ScriptReceivers.create(callback);
var url = Integration.API_URL + "/jsonp/500";
var request;
runs(function() {
request = new JSONPRequest(url, {});
request.send(receiver);
});
waitsFor(function() {
return callback.calls.length > 0;
}, "JSONP to respond", 5000);
runs(function() {
expect(callback.calls.length).toEqual(1);
expect(callback.calls[0].args[1]).toBe(undefined);
request.cleanup();
});
});
});