Skip to content

Commit

Permalink
Refactoring Launchpad and Transport tests to work with Node.
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Nov 30, 2015
1 parent 729cb84 commit ec93a54
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 141 deletions.
14 changes: 12 additions & 2 deletions src/api/Launchpad.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import ClientRequest from './ClientRequest';
import Util from './Util';
import MultiMap from './MultiMap';

var io;

/**
* The main class for making api requests. Sending requests returns a promise that is
* resolved when the response arrives. Usage example:
Expand Down Expand Up @@ -453,6 +455,14 @@ class Launchpad {
return transport.send(clientRequest).then(this.decode);
}

/**
* Sets the socket transport
* @param {Object} socket implementation object.
*/
static socket(socket) {
io = socket;
}

/**
* Adds a sort query to this request's body.
* @param {string} field The field that the query should be sorted by.
Expand Down Expand Up @@ -508,7 +518,7 @@ class Launchpad {
* @return {!io} Socket IO reference. Server events can be listened on it.
*/
watch(opt_params, opt_options) {
if (typeof Launchpad.io === 'undefined') {
if (!io) {
throw new Error('Socket.io client not loaded');
}

Expand All @@ -522,7 +532,7 @@ class Launchpad {
};
opt_options.path = opt_options.path || url[1];

return Launchpad.io(url[0] + '?url=' + encodeURIComponent(url[1] + url[2]), opt_options);
return io(url[0] + '?url=' + encodeURIComponent(url[1] + url[2]), opt_options);
}

/**
Expand Down
Loading

0 comments on commit ec93a54

Please sign in to comment.