From 44c7aa5ab99bba77e4f2af9b5aa974563e08345f Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Fri, 16 Jan 2015 20:04:13 +0200 Subject: [PATCH] Fix parse error We always need to send binary when encoding payloads when sending from server to client, because the polling transport has to know the response type ahead of time. --- lib/index.js | 3 +-- test/browser/index.js | 18 ++++++++++++++++++ test/parser.js | 9 --------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9f474729fb..bd7ea9aaab 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,7 +3,6 @@ */ var utf8 = require('utf8'); -var hasBinary = require('has-binary'); var after = require('after'); var keys = require('./keys'); @@ -227,7 +226,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) { supportsBinary = null; } - if (supportsBinary && hasBinary(packets)) { + if (supportsBinary) { return exports.encodePayloadAsBinary(packets, callback); } diff --git a/test/browser/index.js b/test/browser/index.js index 07a75f47d8..7a60125aeb 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -9,3 +9,21 @@ if (Blob) { } require('./base64_object.js'); + +// General browser only tests +var parser = require('../../'); +var encode = parser.encodePacket; +var decode = parser.decodePacket; +var encPayload = parser.encodePayload; +var decPayload = parser.decodePayload; + +describe('basic functionality', function () { + it('should encode string payloads as strings even if binary supported', function (done) { + encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) { + expect(data).to.be.a('string'); + done(); + }); + }); +}); + + diff --git a/test/parser.js b/test/parser.js index db9d5e58b7..da852d807a 100644 --- a/test/parser.js +++ b/test/parser.js @@ -153,15 +153,6 @@ module.exports = function(parser) { }); }); - describe('basic functionality', function () { - it('should encode string payloads as strings even if binary supported', function (done) { - encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) { - expect(data).to.be.a('string'); - done(); - }); - }); - }); - describe('encoding and decoding', function () { var seen = 0; it('should encode/decode packets', function (done) {