diff --git a/package.json b/package.json index 16e0113..9eeb025 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/basic.test.js b/test/basic.test.js index abc6fa1..1a0ef6c 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -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 () { diff --git a/test/helpers/lifecycle.js b/test/helpers/lifecycle.js index e2d497e..91d1e53 100644 --- a/test/helpers/lifecycle.js +++ b/test/helpers/lifecycle.js @@ -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 @@ -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 = {}; } @@ -38,6 +39,12 @@ 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, @@ -45,16 +52,18 @@ module.exports = { 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); @@ -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;