Skip to content

Commit d90795e

Browse files
committed
fixed bower install + unit tests
1 parent 2cc0862 commit d90795e

File tree

4 files changed

+167
-148
lines changed

4 files changed

+167
-148
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"istanbul": "0.4.0",
4040
"istanbul-middleware": "0.2.1",
4141
"mocha": "2.3.3",
42+
"proxyquire": "^1.7.3",
4243
"rewire": "^2.5.0",
4344
"should": "7.1.1"
4445
}

src/kuzzle.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
var
22
uuid = require('node-uuid'),
3-
io,
43
KuzzleDataCollection = require('./kuzzleDataCollection');
54

6-
if (window && window.io) {
7-
io = window.io;
8-
} else {
9-
io = require('socket.io-client');
10-
}
11-
125
/**
136
* This is a global callback pattern, called by all asynchronous functions of the Kuzzle object.
147
*
@@ -54,6 +47,10 @@ module.exports = Kuzzle = function (url, options, cb) {
5447
reconnected: []
5548
}
5649
},
50+
io: {
51+
value: null,
52+
writable: true
53+
},
5754
queuing: {
5855
value: false,
5956
writable: true
@@ -164,6 +161,12 @@ module.exports = Kuzzle = function (url, options, cb) {
164161
}
165162
});
166163

164+
if (typeof window !== 'undefined' && window.io) {
165+
this.io = window.io;
166+
} else {
167+
this.io = require('socket.io-client');
168+
}
169+
167170
if (options) {
168171
Object.keys(options).forEach(function (opt) {
169172
if (self.hasOwnProperty(opt) && Object.getOwnPropertyDescriptor(self, opt).writable) {
@@ -249,7 +252,7 @@ Kuzzle.prototype.connect = function (cb) {
249252

250253
self.state = 'connecting';
251254

252-
self.socket = io(self.url, {
255+
self.socket = self.io(self.url, {
253256
reconnection: self.autoReconnect,
254257
reconnectionDelay: self.reconnectionDelay,
255258
'force new connection': true

0 commit comments

Comments
 (0)