Skip to content

Commit

Permalink
Upgraded dev dependency to Sails v1 and sails-hook-sockets standalone.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Dec 8, 2016
1 parent 9ddd74c commit 485f3cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"mocha": "3.0.2",
"phantomjs-prebuilt": "2.1.12",
"request": "2.74.0",
"sails": "^0.12.1",
"sails": "^1.0.0-16",
"sails-hook-sockets": "^1.2.3",
"socket.io-client": "1.4.5"
},
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ describe('io.socket', function () {
before(setupRoutes);

it('should connect automatically', function (cb) {
io.socket.on('connect', cb);
// console.log('connecting...');
io.socket.on('connect', function (){
// console.log('connected');
return cb();
});
});

describe('once connected, socket', function () {
Expand Down
20 changes: 16 additions & 4 deletions test/helpers/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

var Sails = require('sails/lib/app');
var SHSockets = require('sails-hook-sockets');
var _ = require('lodash');

// Use a weird port to avoid tests failing if we
Expand All @@ -28,7 +29,7 @@ module.exports = {
var io = require('socket.io-client');
var sailsIO = require('../../sails.io.js');

if (typeof opts == 'function') {
if (_.isFunction(opts)) {
cb = opts;
opts = {};
}
Expand All @@ -38,23 +39,31 @@ module.exports = {
var app = Sails();
app.lift({
log: { level: 'error' },
globals: {
sails: true,
_: false,
async: false,
models: false
},
port: TEST_SERVER_PORT,
sockets: {
authorization: false,
transports: opts.transports,
path: opts.path
},
hooks: {
grunt: false
grunt: false,
sockets: SHSockets
},
routes: {
'/sails.io.js': function(req, res) {
res.header("Content-type","application/javascript");
res.header('Content-type', 'application/javascript');
require('fs').createReadStream(require('path').resolve(__dirname, '..', '..', 'dist', 'sails.io.js')).pipe(res);
}
}
},function (err) {
if (err) return cb(err);
if (err) { return cb(err); }
// console.log('lifted');

// Instantiate socket client.
io = sailsIO(io);
Expand Down Expand Up @@ -125,8 +134,11 @@ module.exports = {
setTimeout(function ensureDisconnect () {

// Tear down sails server
// console.log('lowering...');
global.server.lower(function (){

// console.log('lowered');

// Delete globals (just in case-- shouldn't matter)
delete global.server;
delete global.io;
Expand Down

0 comments on commit 485f3cd

Please sign in to comment.